X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=exec.c;h=c90df6e90516caceb50fee544b27dda49a18eb2a;hp=3c810a3e4cb5c54ed37fec694084574157d8a784;hb=3a6b996d8b39fdc067df352d1eee757ef2a8f49b;hpb=00e4d4da1b2c00da139b09d3ed4ab9ad9fba2691 diff --git a/exec.c b/exec.c index 3c810a3e..c90df6e9 100644 --- a/exec.c +++ b/exec.c @@ -1,16 +1,17 @@ /* - * Copyright (C) 2003-2009 Andre Noll + * Copyright (C) 2003-2014 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ /** \file exec.c Helper functions for spawning new processes. */ -#include + +#include + #include "para.h" -#include "close_on_fork.h" #include "error.h" -#include "string.h" #include "fd.h" +#include "string.h" /** * Spawn a new process and redirect fd 0, 1, and 2. @@ -116,7 +117,7 @@ err_out: * Exec the given command. * * \param pid Will hold the pid of the created process upon return. - * \param cmdline Holds the command and its arguments, seperated by spaces. + * \param cmdline Holds the command and its arguments, separated by spaces. * \param fds A pointer to a value-result array. * * This function uses fork/exec to create a new process. \a fds must be a @@ -129,19 +130,19 @@ err_out: * - fd[i] > 0: create a pipe and dup i to one end of that pipe. * Upon return, fd[i] contains the file descriptor of the pipe. * - * In any case, all unneeded filedescriptors are closed. + * In any case, all unneeded file descriptors are closed. * * \return Standard. */ int para_exec_cmdline_pid(pid_t *pid, const char *cmdline, int *fds) { - int argc, ret; + int ret; char **argv; - char *tmp = para_strdup(cmdline); - argc = split_args(tmp, &argv, " \t"); + ret = create_argv(cmdline, " \t", &argv); + if (ret < 0) + return ret; ret = para_exec(pid, argv[0], argv, fds); - free(argv); - free(tmp); + free_argv(argv); return ret; }