From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8715 invoked by alias); 23 Oct 2014 08:32:49 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33516 Received: (qmail 5450 invoked from network); 23 Oct 2014 08:32:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f4-b7f6c6d00000120b-58-5448bd20f1b1 Date: Thu, 23 Oct 2014 09:32:32 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: bug in zsh wait builtin - rhbz#1150541 Message-id: <20141023093232.1f4201e2@pwslap01u.europe.root.pri> In-reply-to: <141021235542.ZM14840@torch.brasslantern.com> References: <20141021210234.199eee3d@pws-pc.ntlworld.com> <141021235542.ZM14840@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42I5/e/4NV2FvR4hBg87eC0ONj9kcmD0WHXw A1MAYxSXTUpqTmZZapG+XQJXxoS1jawFRwQq2i7MYmxg/MLTxcjJISFgIvH1+Vx2CFtM4sK9 9WxdjFwcQgJLGSXm3f3NDJIQEljOJPGoKRTEZhFQlTjatgasgU3AUGLqptmMILaIgLjE2bXn WUBsYQFjibk77oH18grYS5w7vReshlPASuLjpdksEAs2MUrc630CluAX0Je4+vcTE8QV9hIz r5xhhGgWlPgx+R7YUGYBLYnN25pYIWx5ic1r3jJPYBSYhaRsFpKyWUjKFjAyr2IUTS1NLihO Ss811CtOzC0uzUvXS87P3cQICcIvOxgXH7M6xCjAwajEw1uR7BEixJpYVlyZe4hRgoNZSYQ3 bQdQiDclsbIqtSg/vqg0J7X4ECMTB6dUA2PxJv9PcS+PSCR2Xy1bOvVI6duq9pvyRzb9/DI3 iyPk+eZZnV0vZ3g/vrRI96Fxr8qzLRftLkwVXvryJaOV//5Dv5vFf/27EBnPdF7B/qp+kvDe v3reCx/dVF5y+Ff61H1Pip5zLq/63nj2Q4Z032ThJr6FN61PXXrpyvflvYtym+t+40NR75/o KrEUZyQaajEXFScCAJnfwWAgAgAA On Tue, 21 Oct 2014 23:55:42 -0700 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? No, and as Chet says this appears to be basically "caveat usator". The user needs to be careful / lucky enough to perform their "wait" before the numbers come round again. > Is "kill" supposed to work the same way? There's no indication kill needs to have this. Presumably this is because for kill you don't need to have a sensible exit status, just a reasonable likelihood the job is dead (or wedged in some state where that signal doesn't work, but that's an entirely different problem). > Note also that this is partly handled by the POSIX_JOBS option: > > When the option is set, it becomes possible to use the wait > builtin to wait for the last job started in the background (as > given by $!) even if that job has already exited. This works even > if the option is turned on temporarily around the use of the wait > builtin. > > I would say that any further change made for this should also be under > the auspices (so to speak) of POSIX_JOBS. That would already cover the cases in the "bug" report, in fact. I'm not really sure why we wouldn't just implement this particular feature generally, despite the current status. Is there any reason why you'd *want* "wait" to give you an error (which isn't a particularly useful message) owing to a race condition you can't control? POSIX_JOBS was originally designed for things where the behaviour was clearly incompatible. pws