how to check the status of a process, by ID

Discussion in 'Perl Misc' started by googlegroups.zaphod@truckload2000.com, Feb 13, 2005.

  1. Guest

    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
    , Feb 13, 2005
    #1
    1. Advertising

  2. wrote:

    > 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)

    >
    > Zaphod


    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
    Chris Mattern, Feb 13, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. saha
    Replies:
    0
    Views:
    4,041
  2. Shug
    Replies:
    13
    Views:
    890
    Philipp
    Dec 15, 2006
  3. Shug
    Replies:
    13
    Views:
    946
    Philipp
    Dec 15, 2006
  4. harryos
    Replies:
    0
    Views:
    377
    harryos
    Oct 13, 2010
  5. Sven S.

    status info like rc.status

    Sven S., Dec 9, 2008, in forum: Ruby
    Replies:
    2
    Views:
    169
    Sven S.
    Dec 11, 2008
Loading...

Share This Page