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: Rasmus Villemoes <rv at rasmusvillemoes dot dk>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- 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:54:12 +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> <877fa6nwsl.fsf@mid.deneb.enyo.de>
On Tue, Sep 20 2016, Florian Weimer <fw@deneb.enyo.de> wrote:
> * 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.
Yeah, that's probably ok. It's consistent with its use in pclose() where
the posix description reads "The status of the child process could not
be obtained". We just use it in the sense "something went wrong, we just
don't know what".
I'd really wish EINTERNALBUG existed.
> 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.
Good point. I'll send an updated patch in a moment.
Rasmus