From b094002c5bbf5d68eb187c5ac2dca7000a62ba9d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Aug 2024 01:23:48 +0200 Subject: Run gpu screen recorder as a child process, show notification on start/stop --- src/Process.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/Process.cpp') 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; -- cgit v1.2.3