how to check the status of a process, by ID

  • Thread starter googlegroups.zaphod
  • Start date
G

googlegroups.zaphod

How would you check the status of a process if you have it's id?

for instance; my web host's eMail server uses a lock file "inbox.lock"
which containes the process id of the process that created the
lockfile, to lock access to the inbox file.
If I want to write a script that processes the eMails in the inbox
file.

I check for the existance of the lock file.

If the lock file does not exist, create it and insert my process id.

if the lock file does exist, read the process id out of the lock file
and check to see if the lock is stale (the creating process died
without deleting the file)

How do I chack to see if the process is still running?

Zaphod
 
C

Chris Mattern

How would you check the status of a process if you have it's id?

for instance; my web host's eMail server uses a lock file "inbox.lock"
which containes the process id of the process that created the
lockfile, to lock access to the inbox file.
If I want to write a script that processes the eMails in the inbox
file.

I check for the existance of the lock file.

If the lock file does not exist, create it and insert my process id.

Ack. Race condition!
if the lock file does exist, read the process id out of the lock file
and check to see if the lock is stale (the creating process died
without deleting the file)

How do I chack to see if the process is still running?

Does your email system *really* force you to do this? Doesn't it
use flock? (Which not only can eliminate the race condition,
it takes care of your "is this process running?" problem, too)

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top