One of the idioms often used to check if process is running is to use
kill -s 0 $pid.
My question is, does it have any upsides over using
[[ -e /proc/$pid ]] construct?
The script I'm writing is both Linux and bash specific.
I would prefer
I would generally use a command such as
Additionally using dedicated commands makes for better portability of your code across the various Unixes.
Test process to kill.
Now we kill it.
Were we successful?
A zero means we were successful. Anything else, we could handle it in different ways. With reading the
Same situation, we're attempting to kill a non-existent process.
We get feedback about it.
You may also want to investigate using
There is a major difference between
Which one to use depends on whether you want to match other users' processes.