/* SPDX-License-Identifier: GPL-2.0 */ #include #include #include #include #include #include #include "gcc-compat.h" #include "log.h" #include "err.h" #include "str.h" #include "exec.h" /* Spawn a new process using execvp(). */ void dss_exec(pid_t *pid, const char *file, char *const *const args) { if ((*pid = fork()) < 0) { DSS_EMERG_LOG("fork error: %s\n", strerror(errno)); exit(EXIT_FAILURE); } if (*pid) /* parent */ return; signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); signal(SIGCHLD, SIG_DFL); execvp(file, args); DSS_EMERG_LOG("execvp error: %s\n", strerror(errno)); _exit(EXIT_FAILURE); } /* * Execute the space-separated command line. On return, the pid pointer is * initialized to pid of the newly created process. */ void dss_exec_cmdline_pid(pid_t *pid, const char *cmdline) { char **argv, *tmp = dss_strdup(cmdline); split_args(tmp, &argv); dss_exec(pid, argv[0], argv); free(argv); free(tmp); }