Skip to content

Commit

Permalink
PID read error check.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronamk committed Sep 6, 2021
1 parent fb23971 commit b3d7378
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hkd-relayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ int try_hotkey(key_code key, unsigned int mod_state, pid_t pid, union sigval *ms
int main(int argc, char *argv[]) {
/* find hkd pid */
FILE *cache = popen("pidof hkd", "r");
if (cache == NULL) {
fprintf(stderr, "Error: failed to read hkd pid");
exit(EXIT_FAILURE);
}

char pid_str[20];
fgets(pid_str, 20, cache);
pid_t pid = strtoul(pid_str, NULL, 10);
Expand Down

0 comments on commit b3d7378

Please sign in to comment.