]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virFork: give specific status on failure prior to exec
authorEric Blake <eblake@redhat.com>
Wed, 19 Feb 2014 01:06:50 +0000 (18:06 -0700)
committerEric Blake <eblake@redhat.com>
Mon, 3 Mar 2014 19:40:31 +0000 (12:40 -0700)
commit631923e7f2637c4b74e2e47918e327f87cb1e1a4
treec35f48c2d3eedb35b3f69d31dc1221b909245b8e
parentf972a7c72cb86a9512542de546a20412cf287663
virFork: give specific status on failure prior to exec

When a child fails without exec'ing, we want a well-known status;
best is to match what env(1), nice(1), su(1), and other wrapper
programs do.  This patch adds enum values that later patches will
use, and sets up virFork as the first client of EXIT_CANCELED
for errors detected prior to even attempting exec, as well as
virExec to distinguish between a missing executable vs. a binary
that cannot be executed.

This is a slight semantic change in the unlikely case of a child
process failing to restore its signal mask - we now kill the
child with a known status instead of relying on the caller to
notice and do an appropriate _exit().  A subsequent patch will
make further cleanups based on an audit of all callers.

* src/internal.h (EXIT_CANCELED, EXIT_CANNOT_INVOKE)
(EXIT_ENOENT): New enum.
* src/util/vircommand.c (virFork): Document specific exit value if
child aborts early.
(virExec): Distinguish between various exec failures.
* tests/commandtest.c (test1): Enhance test.
(test22): New test.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/internal.h
src/util/vircommand.c
tests/commandtest.c