]> sourceware.org Git - glibc.git/commit
linux: spawni.c: simplify error reporting to parent
authorRasmus Villemoes <rv@rasmusvillemoes.dk>
Wed, 28 Sep 2016 00:52:17 +0000 (17:52 -0700)
committerAdhemerval Zanella <adhemerval.zanella@linaro.com>
Wed, 28 Sep 2016 18:16:21 +0000 (11:16 -0700)
commit4b4d4056bb154603f36c6f8845757c1012758158
tree6ed027aeae93b6e5970fb6d1ae5eb0a7c1a05851
parent8d3bd947483f50b57aee7c35c07dc1927d6e8a27
linux: spawni.c: simplify error reporting to parent

Using CLONE_VFORK already ensures that the parent does not run until the
child has either exec'ed succesfully or called _exit. Hence we don't
need to read from a CLOEXEC pipe to ensure proper synchronization - we
just make explicit use of the fact the the child and parent run in the
same VM, so the child can write an error code to a field of the
posix_spawn_args struct instead of sending it through a pipe.

To ensure that this mechanism really works, the parent initializes the
field to -1 and the child writes 0 before execing.

This eliminates some annoying bookkeeping that is necessary to avoid
the file actions from clobbering the write end of the pipe, and
getting rid of the pipe creation in the first place means fewer system
calls (four in the parent, usually one in the child) and fewer
chanches for the spawn to fail (e.g. if we're close to EMFILE).

Checked on x86_64 and i686.

* sysdeps/unix/sysv/linux/spawni.c (posix_spawn_args): Remove pipe
field, add err field.
(__spawni_child): Report error through err member instead of pipe.
(__spawnix): Likewise.
ChangeLog
sysdeps/unix/sysv/linux/spawni.c
This page took 0.039105 seconds and 5 git commands to generate.