diff options
Diffstat (limited to 'src/Process.cpp')
-rw-r--r-- | src/Process.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Process.cpp b/src/Process.cpp index cccb889..a1e1e6c 100644 --- a/src/Process.cpp +++ b/src/Process.cpp @@ -40,6 +40,24 @@ namespace gsr { return true; } + pid_t exec_program(const char **args) { + /* 1 argument */ + if(args[0] == nullptr) + return -1; + + pid_t pid = vfork(); + if(pid == -1) { + perror("Failed to vfork"); + return -1; + } else if(pid == 0) { /* child */ + execvp(args[0], (char* const*)args); + perror("execvp"); + _exit(127); + } else { /* parent */ + return pid; + } + } + static bool is_number(const char *str) { while(*str) { char c = *str; |