public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Valtteri Vuorikoski <vuori@notcom.org>
Cc: passt-dev@passt.top, David Gibson <david@gibson.dropbear.id.au>
Subject: Re: passt.c: incorrect signal() return value check
Date: Thu, 13 Apr 2023 13:25:05 +0200	[thread overview]
Message-ID: <20230413132505.2b0c8e52@elisabeth> (raw)
In-Reply-To: <dkohynau5ny3kcdrqb74mkhv4v2bdhc4f3akogg7kimwqix2il@hlgv6l4q7xr6>

Hi Valtteri,

On Thu, 13 Apr 2023 13:24:34 +0300
Valtteri Vuorikoski <vuori@notcom.org> wrote:

> In current master, passt.c:main() has an incorrect check on signal()
> return value:
> 
>                if (sigaction(SIGCHLD, &sa, NULL) || signal(SIGPIPE, SIG_IGN))
>                        die("Couldn't install signal handlers");
> 
> signal() returns SIG_ERR on failure or the previous setting if present. If
> a setting has been inherited from the parent (as is the case when
> starting from systemd with the default setting of IgnoreSIGPIPE=yes),
> the check will fail.

Right, thanks for reporting this.

By the way, feel free to share your systemd unit files, I guess we
could add them under contrib/ in case they are useful for somebody.

> The if statement should check for SIG_ERR for the SIGPIPE case, or
> alternatively switch to sigaction() since that's used for everything
> else in the code.

I guess we could just check SIG_ERR from signal(), it looks a bit
simpler, and perhaps split this into two cases (a failure on signal()
doesn't mean we "[c]ouldn't install signal handlers").

Will you post a patch? It's trivial, so if it's unnecessary effort for
you I can also go ahead and do it.

>  -Valtteri
>  (please cc on replies)

-- 
Stefano


  reply	other threads:[~2023-04-13 13:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13 10:24 passt.c: incorrect signal() return value check Valtteri Vuorikoski
2023-04-13 11:25 ` Stefano Brivio [this message]
2023-04-13 14:47   ` Valtteri Vuorikoski
2023-04-13 17:46     ` Stefano Brivio

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=20230413132505.2b0c8e52@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=vuori@notcom.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 public inbox

	https://passt.top/passt

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 IMAP folder(s).