void check_range(uint32_t val, uint32_t min, uint32_t max, const char *opt);
-bool xexec(char * const argv[], const struct iovec *iov);
+bool xexec(char * const argv[]);
void valid_fd012(void);
void check_name(const char *arg);
void parse_compound_arg(const char *arg, const char *opt, char **name, char **val);
free(ifspec);
INFO_LOG("running pre-start hook %s\n", cmd);
- success = xexec(argv, NULL);
+ success = xexec(argv);
free(cmd);
if (!success)
ERROR_LOG("pre-start hook failed\n");
INFO_LOG("/bin/sh -c '%s'\n", cmd);
set_m7a_root_dir_env(c);
- if (!xexec(argv, NULL))
+ if (!xexec(argv))
die("%s: pre-exec hook failed", c->name);
free(cmd);
unsetenv("MICOFORIA_ROOT_DIR");
if (!OPT_GIVEN(PS, ALL) && !request_init_pid(c->name, &pid))
return false;
sprintf(str, "%d", pid);
- success = xexec(argv, NULL);
+ success = xexec(argv);
return success;
}
char *ed = getenv("EDITOR"); /* must not be freed */
char *conf = get_config_file_path();
char *argv[] = {ed? ed : "vi", conf, NULL};
- bool success = xexec(argv, NULL);
+ bool success = xexec(argv);
free(conf);
return success;
if (tcgetattr(STDIN_FILENO, &tios) >= 0)
tty = true;
}
- success = xexec(argv, NULL);
+ success = xexec(argv);
if (tty) { /* reset terminal settings */
/*
* First give up the controlling terminal. Without this, the
die_lopsub(ret, &errctx);
logfile = get_container_logfile(lls_input(0, sublpr));
argv[1] = logfile;
- success = xexec(argv, NULL);
+ success = xexec(argv);
free(logfile);
return success;
}
}
}
-bool xexec(char * const argv[], const struct iovec *iov)
+bool xexec(char * const argv[])
{
pid_t pid;
- int pipefd[2] = {-1, -1};
unsigned n;
for (n = 0; argv[n]; n++)
DEBUG_LOG("argv[%u]=%s\n", n, argv[n]);
- if (iov) {
- if (pipe(pipefd) < 0)
- die_errno("pipe");
- }
if ((pid = fork()) < 0)
die_errno("fork");
if (pid > 0) { /* parent */
int wstatus;
- bool success = true;
- if (iov) {
- close(pipefd[1]);
- success = fd2buf(pipefd[0], iov);
- close(pipefd[0]);
- }
if (waitpid(pid, &wstatus, 0) < 0)
die_errno("waitp");
- if (!success)
- return false;
if (!WIFEXITED(wstatus))
return false;
if (WEXITSTATUS(wstatus) != EXIT_SUCCESS)
return false;
return true;
}
- if (pipefd[0] >= 0)
- close(pipefd[0]);
- if (pipefd[1] >= 0 && pipefd[1] != STDOUT_FILENO) {
- if (dup2(pipefd[1], STDOUT_FILENO) < 0)
- die_errno("dup2()");
- close(pipefd[1]);
- }
execvp(argv[0], argv);
EMERG_LOG("execvp error: %s\n", strerror(errno));
_exit(EXIT_FAILURE);