My system

Install get ppid:

I have a C program for having all the process tree:

$ cat get-ppid.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>


/*
 * gcc get-ppid.c -o get-ppid && ./get-ppid 3781056
   PID: 3781056
   PID: 3781056; PPID: 3780009; Proc name: (python3)
   PID: 3780009; PPID: 3780005; Proc name: (bash)
   PID: 3780005; PPID: 3779887; Proc name: (sshd)
   PID: 3779887; PPID: 1539; Proc name: (sshd)
   Parent process
   PID: 1539; PPID: 1; Proc name: (sshd)
 */

int get_ppid(const char *pid){
    char filename[64];
    FILE *fd;
    int ppid;
    char proc_name[128];
    char s_ppid[128];
    snprintf(filename, 64, "/proc/%s/stat", pid);

    if ((fd = fopen(filename, "r")) == NULL){
        printf("Failed to open the file\n");
        return -1;
    }

    // 1866044 (name) S 1 1866044
    fscanf(fd, "%*d %s %*c %d", proc_name, &ppid);
    fclose(fd);

    // If parent processes
    if (ppid == 0 || ppid == 1){
        printf("PID: %s; PPID: %d; Proc name: %s\n", pid, ppid, proc_name);
        return 0;
    }

    // Call back this function until we find the parent process
    snprintf(s_ppid, 128, "%d", ppid);
    printf("PID: %s; PPID: %d; Proc name: %s\n", pid, ppid, proc_name);

    return get_ppid(s_ppid);
}

int main(int argc, char *argv[]){
    if (argc == 1)
        return 0;
    get_ppid(argv[1]);

    return 0;
}
$ gcc -o get-ppid get-ppid.c

And copy it to /usr/bin/

$ sudo cp get-ppid /usr/bin/

And we can execute it:

$ get-ppid 89494
PID: 89494; PPID: 83226; Proc name: (docker)
PID: 83226; PPID: 66637; Proc name: (bash)
PID: 66637; PPID: 2470; Proc name: (terminator)
PID: 2470; PPID: 2465; Proc name: (cinnamon)
PID: 2465; PPID: 2217; Proc name: (cinnamon-launch)
PID: 2217; PPID: 2194; Proc name: (cinnamon-sessio)
PID: 2194; PPID: 1531; Proc name: (gdm-x-session)
PID: 1531; PPID: 1059; Proc name: (gdm-session-wor)
PID: 1059; PPID: 1; Proc name: (gdm3)