public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Rich Felker <dalias@libc.org>
To: David Newall <glibc@davidnewall.com>
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH 2/3] posix: Use posix_spawn on popen
Date: Tue, 18 Sep 2018 03:12:00 -0000	[thread overview]
Message-ID: <20180918031240.GR17995@brightrain.aerifal.cx> (raw)
In-Reply-To: <87797b78-a951-f80b-553f-b9e6d208c073@davidnewall.com>

On Tue, Sep 18, 2018 at 11:00:48AM +0930, David Newall wrote:
> On 18/09/18 00:20, Rich Felker wrote:
> >The historical contract of vfork is that you can basically do nothing
> >after it returns in the child except for exec or _exit
> Yes, that is true.  My  understanding is that vfork was intended
> only as a fast way of doing fork/exec sequence.
> 
> >One thing to note is that vfork is completely unsafe to use as
> >documented if any signal handlers are installed, unless you block all
> >signals before calling vfork, in which case the exec'd process will
> >inherit a fully-blocked signal mask which is probably not what you
> >want. Otherwise signal handlers may wrongly run in the child that's
> >sharing memory with the parent.
> 
> You're saying that kernel will deliver a signal to child pid when it
> was parent pid that was signalled.  Can that really happen?

There are various conditions under which signals are delivered to an
entire process group; the most well-known is tty signals from ^C, ^\,
^Z, SIGWINCH, etc. to the tty's foreground process group. After vfork
these would be delivered to both the parent and child while they share
memory. The parent is suspended and won't act until the child execs or
exits, but mere execution of the signal handler in the child is
observably and dangerously wrong behavior.

Rich

  reply	other threads:[~2018-09-18  3:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-15 15:18 [PATCH 1/3] posix: Add internal symbols for posix_spawn interface Adhemerval Zanella
2018-09-15 15:16 ` [PATCH 2/3] posix: Use posix_spawn on popen Adhemerval Zanella
2018-09-16  5:13   ` David Newall
2018-09-17 14:50     ` Rich Felker
2018-09-17 17:32       ` Adhemerval Zanella
2018-09-18  1:31       ` David Newall
2018-09-18  3:12         ` Rich Felker [this message]
2018-09-18 18:01     ` Zack Weinberg
2018-09-19  5:18       ` Rich Felker
2018-09-19 15:53         ` Adhemerval Zanella
2018-10-17 17:20   ` Adhemerval Zanella
2018-10-19 22:08     ` Adhemerval Zanella
2018-09-15 15:18 ` [PATCH 3/3] posix: Use posix_spawn on system Adhemerval Zanella
2018-10-17 20:13   ` Adhemerval Zanella
2018-09-17 12:12 ` [PATCH 1/3] posix: Add internal symbols for posix_spawn interface Florian Weimer
2018-09-17 19:10   ` Adhemerval Zanella
2018-09-21 13:09     ` Florian Weimer
2018-10-17 17:11 ` Adhemerval Zanella

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=20180918031240.GR17995@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=glibc@davidnewall.com \
    --cc=libc-alpha@sourceware.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.
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).