Given the pid of a Linux process, I want to check, from a C program, if the process is still running.
ps -p $PID > /dev/null 2>&1; echo $?
This command return 0 if process with $PID is still running. Otherwise it returns 1.
0
$PID
1
One can use this command in OSX terminal too.