Mercurial > dnft
view spawn.cpp @ 0:4171b2d4684b default tip
initial commit
| author | Yasuri <linuxoverwindows@charliesmp.net> |
|---|---|
| date | Sat, 05 Sep 2026 15:35:48 -0500 |
| parents | |
| children |
line wrap: on
line source
#include <iostream> #include <unistd.h> #include <sys/wait.h> #include <spawn.h> extern char** environ; // idk what this does int spawn(char* const argv[], const char* path) { pid_t pid; int status; status = posix_spawn(&pid, path, NULL, NULL, const_cast<char* const*>(argv), environ); if (status != 0) { std::cerr << "posix_spawn failed:" << strerror(status) << std::endl; return 1; } if (waitpid(pid, &status, 0) == -1) { perror("waitpid"); return 1; } if (WIFEXITED(status)) { return WEXITSTATUS(status); } return 1; }
