From: Eli Zaretskii <eliz@gnu.org>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: phst@google.com, p.stephani2@gmail.com, emacs-devel@gnu.org
Subject: Re: scratch/sigchld-fd 8f0ce42 1/2: Fix deadlock when receiving SIGCHLD during 'pselect'.
Date: Wed, 20 Jan 2021 17:30:53 +0200 [thread overview]
Message-ID: <83k0s77hhu.fsf@gnu.org> (raw)
In-Reply-To: <87czxzx68b.fsf@igel.home> (message from Andreas Schwab on Wed, 20 Jan 2021 11:17:24 +0100)
> From: Andreas Schwab <schwab@linux-m68k.org>
> Cc: emacs-devel@gnu.org, phst@google.com, p.stephani2@gmail.com
> Date: Wed, 20 Jan 2021 11:17:24 +0100
>
> On Jan 20 2021, Eli Zaretskii wrote:
>
> > If/when the signal arrives, the handler removes the file descriptor of the process from the set on which pselect will wait. Isn't that sufficient to prevent us from waiting for a dead process?
>
> Who removes it?
The SIGCHLD signal handler. Or I thought it did, here:
/* If process has terminated, stop waiting for its output. */
if (WIFSIGNALED (status) || WIFEXITED (status))
{
bool clear_desc_flag = 0;
p->alive = 0;
if (p->infd >= 0)
clear_desc_flag = 1;
/* clear_desc_flag avoids a compiler bug in Microsoft C. */
if (clear_desc_flag)
delete_read_fd (p->infd); <<<<<<<<<<<<<<<<<<<<<<<<<
}
But it looks like it only removes the process's file descriptor from
the set to be used for setting up arguments to pselect the _next_
iteration through the loop.
So maybe this is the problem we should solve: make the SIGCHLD handler
reset the bit of the process's output from the fd_set passed to
pselect. Then, if SIGCHLD hits at any time before pselect is called,
it will not wait for output from that process.
> > If not, why not?
>
> What happens when the signal occurs between setting up the set and
> calling pselect?
Yes, see above.
But it sounds like the situation shown in Philipp's log is different.
next prev parent reply other threads:[~2021-01-20 15:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210116184947.2105.45267@vcs0.savannah.gnu.org>
[not found] ` <20210116184949.3C17C211A5@vcs0.savannah.gnu.org>
2021-01-19 15:10 ` scratch/sigchld-fd 8f0ce42 1/2: Fix deadlock when receiving SIGCHLD during 'pselect' Eli Zaretskii
2021-01-19 18:21 ` Philipp Stephani
2021-01-19 19:14 ` Eli Zaretskii
2021-01-19 20:22 ` Philipp Stephani
2021-01-20 15:05 ` Eli Zaretskii
2021-01-23 17:36 ` Philipp Stephani
2021-01-23 18:23 ` Eli Zaretskii
2021-01-23 18:30 ` Philipp Stephani
2021-01-19 20:46 ` Andreas Schwab
2021-01-19 20:58 ` Philipp Stephani
2021-01-20 18:07 ` Andreas Schwab
2021-01-20 3:37 ` Eli Zaretskii
2021-01-20 8:37 ` Andreas Schwab
2021-01-20 8:52 ` Eli Zaretskii
2021-01-20 9:18 ` Andreas Schwab
2021-01-20 10:14 ` Eli Zaretskii
2021-01-20 10:17 ` Andreas Schwab
2021-01-20 15:30 ` Eli Zaretskii [this message]
2021-01-20 15:48 ` Andreas Schwab
2021-01-20 16:40 ` Eli Zaretskii
2021-01-20 16:44 ` Andreas Schwab
2021-01-20 17:03 ` Eli Zaretskii
2021-01-20 17:30 ` Andreas Schwab
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=83k0s77hhu.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=p.stephani2@gmail.com \
--cc=phst@google.com \
--cc=schwab@linux-m68k.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.