bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#52835: [PATCH v4 0/4] Improve safety of start_child and piped-proces


From: Josselin Poiret
Subject: bug#52835: [PATCH v4 0/4] Improve safety of start_child and piped-process.
Date: Sat, 28 May 2022 14:46:30 +0200

retitle 52835 Improve safety of start_child and piped-process.
thanks

Hello everyone,

This time, it's another Guix bug [1] that prompted me to have a closer
look at piped-process and start_child, which don't seem to be very
multi-thread safe.  I've ended up with a couple of improvements that
IMO would make all procedures relying on them more robust.  Here's
roughly what I did:

* Fix the fd closing code that was bogus for unusual values for in,
  out, err for start_child.
* Check for double closes and avoid them, so that we don't
  accidentally close an fd that another thread could have opened.
* Remove some closing code in the child, since we're already
  generically closing all fds.
* Add a pipe from the child to the parent that the former uses to
  report its errno to the latter.  This avoids the use of strerror and
  printf in the child after forking, since they are not async-signal
  safe.  As a side effect, this lets piped-error raise the proper
  system exception for the child errno, instead of returning the PID
  of a process that hasn't exec'd successfully.

[1] https://issues.guix.gnu.org/55441

Best,
Josselin Poiret (4):
  Fix child spawning closing standard fds prematurely.
  Avoid double closes in piped-process.
  Remove useless closing code in start_child.
  Make start_child propagate the child errno to the parent.

 configure.ac     |   3 +-
 libguile/posix.c | 187 ++++++++++++++++++++++++++++++++++-------------
 2 files changed, 138 insertions(+), 52 deletions(-)

-- 
2.36.0






reply via email to

[Prev in Thread] Current Thread [Next in Thread]