5 static inline void close_pair(
int fd[2])
11 static inline void dup_devnull(
int to)
20 int need_in, need_out, need_err;
21 int fdin[2], fdout[2], fderr[2];
42 if (
pipe(fdout) < 0) {
54 if (
pipe(fderr) < 0) {
95 }
else if (cmd->
out > 1) {
100 if (cmd->
dir && chdir(cmd->
dir))
101 die(
"exec %s: cd to %s failed (%s)", cmd->
argv[0],
104 for (; *cmd->
env; cmd->
env++) {
106 putenv((
char*)*cmd->
env);
116 execvp(cmd->
argv[0], (
char *
const*) cmd->
argv);
158 pid_t waiting = waitpid(pid, &status, 0);
168 if (WIFSIGNALED(status))
171 if (!WIFEXITED(status))
173 code = WEXITSTATUS(status);
187 return wait_or_whine(cmd->
pid);
202 memset(cmd, 0,
sizeof(*cmd));
212 prepare_run_command_v_opt(&cmd, argv, opt);