bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: builtin man page for wait omits information from SIGNALS


From: AA
Subject: Re: builtin man page for wait omits information from SIGNALS
Date: Wed, 15 Jun 2022 12:14:22 -0700
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0

Greg:  I included a link to the github. There are only 3 PRs, one of which is mine. That's why I was suspicious it's the wrong place.

Here is a link to the actual patch: https://github.com/gitGNU/gnu_bash/pull/5/files

Robert: Yes, I meant the section of "man bash" that discusses the builtins, not man 2 wait, or some unrelated man page.

I am unaware of the man page politics of gnu bash. Therefore, if you could educate/direct me to the right place to ensure the patch at the link above is considered, I'd be happy to follow up. Seems to me at least an xref to the SIGNALS section seems warranted. One otherwise has to have read the entire man page to happen across this "early exit" behavior of wait. I suppose that's why wizards have long beards.


What follows touches on aspects of wait and bash that lead to the foregoing doc PR.

when implementing a wrapper for an external executable running a kubernetes pod, I catch SIGTERM, forward it to the child process, and then I wish to wait for the child process to actually terminate. I do this by:

_sigterm() {   kill -TERM 6; 2>/dev/null; }; trap _sigterm SIGTERM;  python foo.py  2>&1 | rotatelogs -v -e -L foo.log foo.logfile.%Y-%m-%d-%H_%M_%S 1G 2>> rotatelogs.log & wait 6; wait 6; }

(1) The wait 6 is a reference to the PID of python. It's always the same because the pod startup is deterministic. Getting at that PID symbolically seems quite painful. It wasn't clear from the manpage if %- would give me that PID, nor did I find any good way to refer to the job IDs of members of the most recent pipe. If it doesn't exist, this would seem to be a useful addition to the bash jobs reference variable syntax. If %- works then perhaps the syntax could be %-N to refer to the N'th back PID in the most recent pipe built by bash?

Building a named pipe so I can execute the components separately in order to access $! seems absurdly roundabout. I refuse! :)

(2) The double wait 6 is so that the parent bash doesn't immediately die after delivering the SIGTERM to the child python. It wasn't clear from the man page whether one can or should wait inside a signal handler function. Would that have been the better place to put the second wait 6? Perhaps it's exactly equivalent. Does the answer warrant an additional doc PR? Happy to write it.

All the best,
A.



On 6/15/22 5:52 AM, Robert Elz wrote:
     Date:        Wed, 15 Jun 2022 07:37:07 -0400
     From:        Greg Wooledge<greg@wooledge.org>
     Message-ID:<YqnEYyQUBSeT7WEB@wooledge.org>

   | Bash does not ship a man page named "wait".  What are you actually
   | reading?

I assumed the section of "man bash" which describes the wait
builtin command, describes the various exit status possibilities
from wait, but doesn't mention the case where wait is interrupted.

Whether it is worth mentioning there, or providing a "for what
happens if a signal occurs during the wait see..." xref isn't
my call, but it is a notable omission.

kre


reply via email to

[Prev in Thread] Current Thread [Next in Thread]