From: "Steve Graegert" <graegerts@gmail.com>
To: Prasanta Sadhukhan <Prasanta.Sadhukhan@sun.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Running status of a process
Date: Wed, 21 Mar 2007 09:30:18 +0100 [thread overview]
Message-ID: <6a00c8d50703210130x2722d05dy84673996da81b4aa@mail.gmail.com> (raw)
In-Reply-To: <4600E921.5010106@sun.com>
Prasanta,
On 3/21/07, Prasanta Sadhukhan <Prasanta.Sadhukhan@sun.com> wrote:
> Hi,
>
> Can anyone point as to how can I obtain the information whether a
> non-child process is still running?
If you know the PID of the process you want to obtain the status of
use the kill(2) system call. The second argument should be 0 (zero)
to prevent a signal from being sent to the process. If the process
exists kill(2) returns zero, or -1 otherwise.
kill(2) can indicate various errors, but an error or EPERM usually is
an indicator that the process exists, while all others indicate that
it does not.
If you're writing for systems supporting the /proc filesystem,
checking for existence of /proc/{pid} is an alternative.
If you don't know the PID you're out of luck, unless you make use of
the /proc filesystem again, which is not portable per se.
\Steve
--
Steve Grägert <steve@graegert.com>
Jabber xmpp://graegerts@jabber.org
Internet http://eth0.graegert.com, http://blog.graegert.com
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2007-03-21 8:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-21 8:13 Running status of a process Prasanta Sadhukhan
2007-03-21 8:30 ` Steve Graegert [this message]
2007-03-21 8:34 ` Prasanta Sadhukhan
2007-03-21 8:33 ` Prasanta Sadhukhan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a00c8d50703210130x2722d05dy84673996da81b4aa@mail.gmail.com \
--to=graegerts@gmail.com \
--cc=Prasanta.Sadhukhan@sun.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).