The are many scenarios where it is necessary to keep track of spawned process PID's and kill them either gently (e.g. a
In PHP there is an easy way to get the current processID of the running script. The function is aptly named
SIGTERM
via taskkill /PID
on Windows or kill -15
on Linux,MacOS) or not so gently (e.g. SIGKILL
via taskkill /F /PID
on Windows or kill -9
on Linux,MacOS).In PHP there is an easy way to get the current processID of the running script. The function is aptly named
getmypid()
. To facilitate easy termination of a process, such as a process spawned by a PHP script via popen
or exec
, I wrote a concise one-liner:Loading...