From: Clemens Ladisch <clemens@ladisch.de>
To: "Leonidas ." <leonidas137@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Process id recycling and status of tasks
Date: Fri, 23 Oct 2009 10:13:24 +0200 [thread overview]
Message-ID: <4AE165A4.70706@ladisch.de> (raw)
In-Reply-To: <f22d86810910220629o433ee5d0u9857d1fb1f01cd6@mail.gmail.com>
Leonidas . wrote:
> 1. What would be an ideal way to check if a task is alive or dead from
> kernel space?
Get a reference to the task's pid (call get_task_pid(), or get_pid() on
the return value of task_pid()), then later check whether pid_task()
works.
(pid_alive() is not what you want because this would require that you
hold a reference to the task_struct.)
> even though a certain pid might exist, it might have got recycled by
> the time I check again, right?
The functions above do not work with PID numbers but with struct pid
which is a reference-counted object. (The functions with "get" in their
name increase the reference count, so don't forget to put_pid() when you
no longer need it.) See also the big comment in include/linux/pid.h.
HTH
Clemens
next prev parent reply other threads:[~2009-10-23 8:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-22 13:29 Process id recycling and status of tasks Leonidas .
2009-10-23 8:13 ` Clemens Ladisch [this message]
2009-10-24 18:07 ` Leonidas .
2009-10-25 10:49 ` Leonidas .
2009-10-26 8:41 ` Clemens Ladisch
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=4AE165A4.70706@ladisch.de \
--to=clemens@ladisch.de \
--cc=leonidas137@gmail.com \
--cc=linux-kernel@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