I think the simplest thing would be to open “/proc” and parse the contents.
You’ll find the ppid as the 4th parameter of /proc/pid/stat
In C, libproc has a get_proc_stats
function for parsing that file: see Given a child PID how can you get the parent PID for an example.