public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix scoped_ignore_sigpipe selftest on systems with BSD signal semantics
Date: Thu, 17 Jun 2021 14:05:14 -0700	[thread overview]
Message-ID: <ccdb9d70-4004-2c08-ebff-b6c0109084fd@FreeBSD.org> (raw)
In-Reply-To: <20210617185545.3826154-1-pedro@palves.net>

On 6/17/21 11:55 AM, Pedro Alves wrote:
> The new "maint selftest scoped_ignore_sigpipe" unit test currently
> fails on Solaris, and probably on all BSDs.  The problem is that the
> test registers a SIGPIPE signal handler, and doesn't account for BSD
> semantics where we need to rearm the signal disposition every time the
> signal handler is called.  The result is that GDB dies from SIGPIPE
> because the test triggers a SIGPIPE more than once:
> 
>   $ gdb -q -ex "maint selftest scoped_ignore_sigpipe"
>   Running selftest scoped_ignore_sigpipe.
>   $
>   (gdb exited due to SIGPIPE)
> 
> Fix this by using sigaction.  I'm not adding the usual #ifdef
> HAVE_SIGACTION goo, because I really want to believe that all systems
> that support SIGPIPE support sigaction nowadays.  GNU/Linux, Hurd,
> BSDs, macOS, Cygwin, DJGPP, AIX, etc., anything resembling a modern
> Unix does support it AFAIK, only mingw does not support it, but OTOH,
> it also doesn't define SIGPIPE.  Confirmed by cross building GDB for
> mingw-w64.

FWIW, BSD's dropped this behavior long ago.  FreeBSD passes the existing
test currently with gdb master.  There's a comment about this in the
signal(3) manpage on FreeBSD (and likely others) that goes back to 4.2BSD:

      The handled signal is unblocked when the function returns and the process
      continues from where it left off when the signal occurred.  Unlike
      previous signal facilities, the handler func() remains installed after a
      signal has been delivered.

The comment was added in this commit in 1985:

    https://svnweb.freebsd.org/csrg?view=revision&revision=20133

That said, using sigaction directly seems fine to me.

-- 
John Baldwin

  reply	other threads:[~2021-06-17 21:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 18:55 Pedro Alves
2021-06-17 21:05 ` John Baldwin [this message]
2021-06-17 21:23   ` [pushed] Fix scoped_ignore_sigpipe selftest on systems with SysV " Pedro Alves
2021-06-22 13:49 ` [PATCH] Fix scoped_ignore_sigpipe selftest on systems with BSD " Tom Tromey
2021-06-22 19:00   ` Pedro Alves

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=ccdb9d70-4004-2c08-ebff-b6c0109084fd@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).