diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-08-02 01:23:48 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-08-02 01:23:48 +0200 |
commit | b094002c5bbf5d68eb187c5ac2dca7000a62ba9d (patch) | |
tree | ecdc418a625a19f79b7db712b247b2306a6b2631 /src/Process.cpp | |
parent | 495bd6bed85c85650620dc2ae91f7f058ae2da5c (diff) |
Run gpu screen recorder as a child process, show notification on start/stop
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; |