Hello all,
I am interested in testing for a running process and, if it is not running, restarting it.
Right now, I'm writing /tmp/app.pid files for everything I run. If I need to stop a running app, I call:
(destroy-pid (int (read-file "/tmp/app.pid")))
Which works, of course.
But, I want to test to see if the pid is actually running. Is there a clean, easy way to do this (something I am missing in unix.lsp, for example?)
Thanks.
Send 0 to a process using 'kill' - it will return true if the process is running (and accepting signals), nil if it isn't. So, after loading unix.lsp:
(kill pid 0)
will return true if PID is running. That's assuming you know the process ID .. :) If you don't know the PID, then you could use ps -ef | grep "name" to get it...
So simple!
Thanks. That's exactly what I was missing. No idea why it didn't occur to me.
Perfect. Thanks!
Quote from: "cormullion"
Send 0 to a process using 'kill' - it will return true if the process is running (and accepting signals), nil if it isn't. So, after loading unix.lsp:
(kill pid 0)
will return true if PID is running. That's assuming you know the process ID .. :) If you don't know the PID, then you could use ps -ef | grep "name" to get it...