This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2 3/3] posix: New Linux posix_spawn{p} implementation
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Rasmus Villemoes <rv at rasmusvillemoes dot dk>
- Cc: Joseph Myers <joseph at codesourcery dot com>, libc-alpha at sourceware dot org, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Date: Tue, 20 Sep 2016 22:25:30 +0200
- Subject: Re: [PATCH v2 3/3] posix: New Linux posix_spawn{p} implementation
- Authentication-results: sourceware.org; auth=none
- References: <1454343665-1706-1-git-send-email-adhemerval.zanella@linaro.org> <1454343665-1706-4-git-send-email-adhemerval.zanella@linaro.org> <87mvjsprqb.fsf@rasmusvillemoes.dk> <alpine.DEB.2.20.1608312206510.24256@digraph.polyomino.org.uk> <CAKwiHFiuZVLX+S8b7OZxJfcdvZ2mjWV6p0CAnQRJHOfHcmn-HQ@mail.gmail.com>
* Rasmus Villemoes:
> + /* errno should have an appropriate non-zero value, but make sure
> + that's the case so that our parent knows we failed to
> + exec. There's no EUNKNOWN or EINTERNALBUG, so we use a value
> + which is clearly bogus. */
> + args->err = errno ? : EHOSTDOWN;
> _exit (SPAWN_ERROR);
> }
I think ECHILD is probably a better fake error code.
You should set args->err to 0 on success ...
> + args.err = 0;
... and initialize it to -1.
> if (new_pid > 0)
> {
> - if (__read (args.pipe[0], &ec, sizeof ec) != sizeof ec)
> - ec = 0;
> - else
> + ec = args.err;
> + if (ec != 0)
> __waitpid (new_pid, NULL, 0);
> }
You should check (assert?) here that args.err is not -1. Otherwise we
will never notice if the page is not shared between parent and child,
and the error reporting mechanism does not work.