diff options
Diffstat (limited to 'src/Process.cpp')
-rw-r--r-- | src/Process.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Process.cpp b/src/Process.cpp index 347c485..c5fcf0f 100644 --- a/src/Process.cpp +++ b/src/Process.cpp @@ -59,7 +59,7 @@ namespace gsr { const pid_t second_child = vfork(); if(second_child == 0) { // child execvp(args[0], (char* const*)args); - perror("execvp"); + perror(args[0]); _exit(127); } else if(second_child != -1) { // TODO: @@ -98,7 +98,7 @@ namespace gsr { close(fds[PIPE_WRITE]); execvp(args[0], (char* const*)args); - perror("execvp"); + perror(args[0]); _exit(127); } else { /* parent */ close(fds[PIPE_WRITE]); @@ -206,7 +206,7 @@ namespace gsr { return false; } - pid_t pidof(const char *process_name) { + pid_t pidof(const char *process_name, pid_t ignore_pid) { pid_t result = -1; DIR *dir = opendir("/proc"); if(!dir) @@ -222,8 +222,11 @@ namespace gsr { snprintf(cmdline_filepath, sizeof(cmdline_filepath), "/proc/%s/cmdline", entry->d_name); if(read_cmdline_arg0(cmdline_filepath, arg0, sizeof(arg0)) && strcmp(process_name, arg0) == 0) { - result = atoi(entry->d_name); - break; + const pid_t pid = atoi(entry->d_name); + if(pid != ignore_pid) { + result = pid; + break; + } } } |