Voting

: five minus zero?
(Example: nine)

The Note You're Voting On

Avital Yachin
7 years ago
posix_getppid will not work on Windows.
Here's an alternative:

<?php
if(strncasecmp(PHP_OS, "win", 3) == 0) {
$pid = getmypid(); // child process ID
$parent_pid = shell_exec("wmic process where (processid=$pid) get parentprocessid");
$parent_pid = explode("\n", $parent_pid);
$parent_pid = intval($parent_pid[1]);

echo
"Child: $pid Parent: $parent_pid\n";
}
?>

<< Back to user notes page

To Top