Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15963

Re: "wait" loses signals

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Denys Vlasenko <dvlasenk@redhat.com>
Newsgroups gnu.bash.bug
Subject Re: "wait" loses signals
Date Mon, 24 Feb 2020 18:19:46 +0100
Lines 22
Approved bug-bash@gnu.org
Message-ID <mailman.1505.1582564797.2412.bug-bash@gnu.org> (permalink)
References <dab35be8-4b56-5887-bfa4-37ea7383864a@case.edu> <750d460d-b8a4-4157-1488-9f4d9f973715@redhat.com> <35034c85-fd5a-5034-a2d5-e3903888069d@case.edu> <cf7adbec-e705-1071-34e1-50f8188f0edc@redhat.com> <d60f1dbc-990d-7291-e075-b67c07f61a86@case.edu> <00620c20-19ea-e71e-dc1b-926847901f82@redhat.com> <25750.1582534783@jinx.noi.kre.to> <96ce0406-36fd-f93e-6ebc-49bd58b52148@case.edu> <a7e82b8b-046e-dbac-2f10-3f4dcac69f72@redhat.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1582564798 15507 209.51.188.17 (24 Feb 2020 17:19:58 GMT)
X-Complaints-To action@cs.stanford.edu
Cc Harald van Dijk <harald@gigawatt.nl>, Daniel Colascione <dancol@google.com>, bug-bash@gnu.org
To chet.ramey@case.edu, Robert Elz <kre@munnari.OZ.AU>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582564793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SUKASOV7+DiIT5lULOyaUG65zgrFlZNQUXdM56xWDH4=; b=Mnj69D1WYQo1QyObJW6qV9qoG3ZODScmi+QxYQUXzOBwfIV/haeZtTcyNwBomtKtLh4bnz PDT3H3UQQusNWiU/VKyXL6LtcuePq1jXYPpaBRfIAqHQTM/ZiD2GHlvIVWYIDaekOCnGgr +wxYKILdOPZpNfBMvxRcXuZ7lcKjhhw=
X-MC-Unique TGTXJvI2NXyWMcqTpVJuow-1
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0
In-Reply-To <96ce0406-36fd-f93e-6ebc-49bd58b52148@case.edu>
Content-Language en-US
X-Scanned-By MIMEDefang 2.79 on 10.5.11.15
X-Mimecast-Spam-Score 0
X-Mimecast-Originator redhat.com
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 205.139.110.120
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <a7e82b8b-046e-dbac-2f10-3f4dcac69f72@redhat.com>
X-Mailman-Original-References <dab35be8-4b56-5887-bfa4-37ea7383864a@case.edu> <750d460d-b8a4-4157-1488-9f4d9f973715@redhat.com> <35034c85-fd5a-5034-a2d5-e3903888069d@case.edu> <cf7adbec-e705-1071-34e1-50f8188f0edc@redhat.com> <d60f1dbc-990d-7291-e075-b67c07f61a86@case.edu> <00620c20-19ea-e71e-dc1b-926847901f82@redhat.com> <25750.1582534783@jinx.noi.kre.to> <96ce0406-36fd-f93e-6ebc-49bd58b52148@case.edu>
Xref csiph.com gnu.bash.bug:15963

Show key headers only | View raw


On 2/24/20 5:18 PM, Chet Ramey wrote:
> The first case is trickier: there's always going to be a window between
> the time the shell checks for pending traps and the time the wait builtin
> starts to run. You can't really close it unless you're willing to run the
> trap out of the signal handler, which everyone agrees is a bad idea, but
> you can squeeze it down to practially nothing.

dash uses something along these lines:

         sigfillset(&mask);
         sigprocmask(SIG_SETMASK, &mask, &mask);
         while (!pending_sig)
                 sigsuspend(&mask);
         sigprocmask(SIG_SETMASK, &mask, NULL);
         if (pending_sig)
                 handle_signals(pending_sig);
         pid = waitpid(... WNOHANG);

It sleeps in sigsuspend(), not in waitpid(). This way we wait for both
signals *and* children (by virtue of getting SIGCHLD for them).

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: "wait" loses signals Denys Vlasenko <dvlasenk@redhat.com> - 2020-02-24 18:19 +0100

csiph-web