From: Chet Ramey <chet.ramey@case.edu>
To: Bart Schaefer <schaefer@brasslantern.com>, zsh-workers@zsh.org
Cc: chet.ramey@case.edu
Subject: Re: bug in zsh wait builtin - rhbz#1150541
Date: Wed, 22 Oct 2014 14:32:38 -0400 [thread overview]
Message-ID: <5447F846.5050300@case.edu> (raw)
In-Reply-To: <141021235542.ZM14840@torch.brasslantern.com>
On 10/22/14, 2:55 AM, Bart Schaefer wrote:
> On Oct 21, 9:02pm, Peter Stephenson wrote:
> }
> } There's an explanatory note in the latest POSIX standard about this,
> } quoted below. It seems that the shell is basically required to remember
> } all background processes indefinitely (up to not very helpful get out
> } clauses). As a baseline, CHILD_MAX here is 1024. This probably needs
> } to be a special hash.
>
> Since you've bothered to look this up ... does it go on to say what the
> shell is supposed to do if PIDs roll over so that a new background job
> gets the same $! as some previous one? Is "kill" supposed to work the
> same way? (Do we need to send an inquiry to austin-group? If so, you
> will have to do it, my ability to post there has been messed up for a
> long time.)
The implicit assumption in the Posix spec is that the pid space is large:
large enough that PIDs won't roll over and collide before you've gone
through CHILD_MAX children. In practice, it happens surprisingly often.
The way I do it is to add the PIDs of exited jobs to a list, and prune it
if the list gets longer than the current child_max. I check after fork()
and remove pids from the list if they recycle.
`wait' knows how to look through this list for child PID statuses.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
next prev parent reply other threads:[~2014-10-22 18:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 7:53 Tim Speetjens
2014-10-21 20:02 ` Peter Stephenson
2014-10-22 6:55 ` Bart Schaefer
[not found] ` <CAO7vJOjrb=N3xuTJVSb7U8mdXtexYp8nN4YaoknfUb3fofU2zg@mail.gmail.com>
2014-10-22 15:48 ` Bart Schaefer
2014-10-22 18:32 ` Chet Ramey [this message]
2014-10-23 8:32 ` Peter Stephenson
2014-10-24 4:50 ` Bart Schaefer
2014-10-24 8:04 ` Tim Speetjens
2014-10-25 19:08 ` Peter Stephenson
2014-10-25 21:54 ` Bart Schaefer
2014-10-25 22:28 ` Bart Schaefer
2014-10-25 22:32 ` Bart Schaefer
2014-10-25 23:04 ` Peter Stephenson
2014-10-25 23:17 ` Peter Stephenson
2014-10-26 19:01 ` Peter Stephenson
2014-10-26 20:41 ` Bart Schaefer
2014-10-26 21:22 ` Peter Stephenson
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=5447F846.5050300@case.edu \
--to=chet.ramey@case.edu \
--cc=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).