about summary refs log tree commit diff
path: root/posix/tst-spawn3.c
diff options
context:
space:
mode:
authorRasmus Villemoes <rv@rasmusvillemoes.dk>2016-09-27 17:52:17 -0700
committerAdhemerval Zanella <adhemerval.zanella@linaro.com>2016-09-28 11:16:21 -0700
commit4b4d4056bb154603f36c6f8845757c1012758158 (patch)
tree6ed027aeae93b6e5970fb6d1ae5eb0a7c1a05851 /posix/tst-spawn3.c
parent8d3bd947483f50b57aee7c35c07dc1927d6e8a27 (diff)
downloadglibc-4b4d4056bb154603f36c6f8845757c1012758158.tar.gz
glibc-4b4d4056bb154603f36c6f8845757c1012758158.tar.xz
glibc-4b4d4056bb154603f36c6f8845757c1012758158.zip
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.
Diffstat (limited to 'posix/tst-spawn3.c')
0 files changed, 0 insertions, 0 deletions