This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/3] PR remote/19496, interrupted syscall in forking-threads-plus-bkpt
- From: Pedro Alves <palves at redhat dot com>
- To: Don Breazeal <donb at codesourcery dot com>, gdb-patches at sourceware dot org
- Date: Mon, 01 Feb 2016 19:38:15 +0000
- Subject: Re: [PATCH 2/3] PR remote/19496, interrupted syscall in forking-threads-plus-bkpt
- Authentication-results: sourceware.org; auth=none
- References: <1453942111-1215-1-git-send-email-donb at codesourcery dot com> <1453942111-1215-3-git-send-email-donb at codesourcery dot com>
On 01/28/2016 12:48 AM, Don Breazeal wrote:
> This patch addresses "fork:Interrupted system call" (or wait:) failures
> in gdb.threads/forking-threads-plus-breakpoint.exp.
>
> The test program spawns ten threads, each of which do ten fork/waitpid
> sequences. The cause of the problem was that when one of the fork
> children exited before the corresponding fork parent could initiate its
> waitpid for that child, a SIGCHLD was delivered and interrupted a fork
> or waitpid in another thread.
>
> The fix was to wrap the system calls in a loop to retry the call if
> it was interrupted, like:
>
> do
> {
> pid = fork ();
> }
> while (pid == -1 && errno == EINTR);
>
> Since this is a Linux-only test I figure it is OK to use errno and EINTR.
>
> Tested on Nios II Linux target with x86 Linux host.
I'd prefer to avoid this if possible. These loops potentially hide
bugs like ERESTARTSYS escaping out of a syscall and mishandling of
signals. See bc9540e842eb5639ca59cb133adef211d252843c for example:
https://sourceware.org/ml/gdb-patches/2015-02/msg00654.html
How about setting SIGCHLD to SIG_IGN, or making SIGCHLD be SA_RESTART?
Thanks,
Pedro Alves