lsof ist genauso ein „bash befehl“ wie kill, naemlich gar nicht. Der korrekte Weg geht auch nicht ueber pcntl, sondern ueber
posix_kill, das macht den Syscall direkt und spart sich diesen ganzen Shell-Umweg-Wix. Den Rueckgabewert kriegt man dann mit
posix_get_last_error,
kill(2) ist dein Freund. Bringen tut das aber auch nichts, weil man fuer alle interessanten Prozesse (naemlich alle die, deren echte UID, die nicht mit den echten oder effektiven UIDs des Webservers laeuft) EPERM bekommt:
CODE
mmarx@korenchkin (1487) ~ % id
uid=1000(mmarx) gid=1000(mmarx) groups=20(dialout),24(cdrom),25(floppy),29(audio),44(video),46(plugdev),109(kvm),1000(mmarx),1001(wheel)
mmarx@korenchkin (1488) ~ % ps -U root | tail -n1
29450 ? 00:00:00 logger
mmarx@korenchkin (1489) ~ % strace kill -0 29450 2>&1 | grep '^kill('
kill(29450, SIG_0) = -1 EPERM (Operation not permitted)
mmarx@korenchkin (1490) ~ %
Unter Linux koennte man mit capabilities (CAP_KILL) darum kommen, muss man aber schon _tierisch_ bescheurt sein, um so etwas einem Webserver anzuvertrauen. Gleiches gilt fuer Webserver mit Nutzer- oder gar root-Rechten. Wer auf Schmerzen steht (gar nicht mal so abwegig, immerhin geht es um PHP), kann
suPHP nehmen.
In my talons, I shape clay, crafting life forms as I please.
Around me is a burgeoning empire of steel.
From my throne room, lines of power careen into the skies of Earth.
My whims will become lightning bolts that devastate the mounds of humanity.
Out of the chaos, they will run and whimper, praying for me to end their tedious anarchy.
I am drunk with this vision. God: the title suits me well.