From: Hubertus Franke <frankeh@watson.ibm.com>
To: root@chaos.analogic.com, Linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: if_exist_pid()
Date: Fri, 19 Jul 2002 10:55:40 -0400 [thread overview]
Message-ID: <200207191055.40646.frankeh@watson.ibm.com> (raw)
In-Reply-To: <Pine.LNX.3.95.1020716131206.19310A-100000@chaos.analogic.com>
On Tuesday 16 July 2002 01:19 pm, Richard B. Johnson wrote:
> Anybody know the 'correct' way of determining if a pid still
> exists? I've been using "kill(pid, 0)" and, if it does not
> return an error, it is supposed to exist. This is to release
> a user-mode lock (semaphore) if the task that held the lock
> crashed. Maybe there is a 'if_exist_pid(pid)' call somewhere?
> Sending signal 0 to a pid sometimes returns 0, even if the pid
> is long-gone and I don't want to read /proc to look for info.
>
> Cheers,
> Dick Johnson
>
> Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
>
> Windows-2000/Professional isn't.
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
You can take your clues from the get_pid algo and implementation.
The currently correct way to do this is to
scan all tasks and figure out whether either of pid, gid, tgid .. is using
your questioned pid number for small number of task this should be
trivial timewise, for large number of task its a different story
Bill Irwin is working on a patch that release pids upon their last usage
and such thing could then be recorded in a bitmap. Checking availability
would simply then mean checking a particular bit.
I have a patch lying around to move pid allocation to a bitmap.
--
-- Hubertus Franke (frankeh@watson.ibm.com)
prev parent reply other threads:[~2002-07-19 15:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-16 17:19 if_exist_pid() Richard B. Johnson
2002-07-16 17:42 ` if_exist_pid() Kasper Dupont
2002-07-19 14:55 ` Hubertus Franke [this message]
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=200207191055.40646.frankeh@watson.ibm.com \
--to=frankeh@watson.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=root@chaos.analogic.com \
/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