[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libxl: Make libxl_exec tolerate foofd<=2
commit 162f0185f7d5bb9ac84ebd511921c50e7dbe870d Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> AuthorDate: Tue Mar 18 17:04:36 2014 +0000 Commit: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CommitDate: Wed Mar 19 13:40:24 2014 +0000 libxl: Make libxl_exec tolerate foofd<=2 Make passing 0, 1, or 2 as stdinfd, stdoutfd or stderrfd work properly. Also, document the meaning of the fd arguments. Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CC: Roger Pau Monne <roger.pau@xxxxxxxxxx> CC: Vasiliy Tolstov <v.tolstov@xxxxxxxxx> Acked-by: Ian Campbell <Ian.Campbell@xxxxxxxxxx> --- tools/libxl/libxl_exec.c | 6 +++--- tools/libxl/libxl_internal.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c index 4b012dc..478b4c2 100644 --- a/tools/libxl/libxl_exec.c +++ b/tools/libxl/libxl_exec.c @@ -77,11 +77,11 @@ void libxl__exec(libxl__gc *gc, int stdinfd, int stdoutfd, int stderrfd, if (stderrfd != -1) dup2(stderrfd, STDERR_FILENO); - if (stdinfd != -1) + if (stdinfd > 2) close(stdinfd); - if (stdoutfd != -1 && stdoutfd != stdinfd) + if (stdoutfd > 2 && stdoutfd != stdinfd) close(stdoutfd); - if (stderrfd != -1 && stderrfd != stdinfd && stderrfd != stdoutfd) + if (stderrfd > 2 && stderrfd != stdinfd && stderrfd != stdoutfd) close(stderrfd); check_open_fds(arg0); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 69d2ba8..17890ef 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1418,6 +1418,11 @@ _hidden int libxl__xenstore_child_wait_deprecated(libxl__gc *gc, * * The last entry of the array always has to be NULL. * + * stdinfd, stdoutfd, stderrfd will be dup2'd onto the corresponding + * fd in the child, if they are not -1. The original copy of the + * descriptor will be closed in the child (unless it's 0, 1 or 2 + * ie the source descriptor is itself stdin, stdout or stderr). + * * Logs errors, never returns. */ _hidden void libxl__exec(libxl__gc *gc, int stdinfd, int stdoutfd, -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |