Skip to content

Commit

Permalink
error handling for -p flag
Browse files Browse the repository at this point in the history
Signed-off-by: kernaltrap8 <[email protected]>
  • Loading branch information
kernaltrap8 committed Jun 19, 2024
1 parent 882cc0a commit 2c5a109
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/proctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ int main(int argc, char *argv[]) {
}

if (!strcmp(argv[1], "-p") || !strcmp(argv[1], "--pid")) {
printf("%i", get_pid_by_name(argv[2]));
int pid = get_pid_by_name(argv[2]);
if (pid != -1) {
printf("%i", pid);
} else {
printf("Unable to locate process \"%s\".\n", argv[2]);
return 1;
}
return 0;
}

Expand Down

0 comments on commit 2c5a109

Please sign in to comment.