when using proc_open, the child's ppid is NOT your php script, but rather a shell started by proc_open's pid. to get your pid, your proc_open child needs to get the parent's parent's (aka grandparent's) pid. here's a way to do that in PHP on linux:
function posix_getpppid(): int {
return ( int ) (explode ( " ", file_get_contents ( "/proc/" . posix_getppid () . "/stat" ) ) [3]);
}
(thanks to TML @ irc.freenode.net/##PHP for the technique)
(i said most of this in a previous comment, but i didn't have a good solution for it. now i have. if someone with the privileges read this, can you delete this notice and my previous comment please?)