Skip to content

Commit

Permalink
Fix getting ppid in get_process_ttyname for Linux.
Browse files Browse the repository at this point in the history
The ppid field in /proc/self/stat is the fourth and not the third.
The latter is the process state (S, R, etc.).

Signed-off-by: Ignacy Gawędzki <[email protected]>
  • Loading branch information
iazz authored and millert committed Jan 15, 2025
1 parent 01b1410 commit 5794e51
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ttyname.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ get_process_ttyname(char *name, size_t namelen)
}
break;
}
if (field == 3) {
if (field == 4) {
ppid =
(int)sudo_strtonum(cp, INT_MIN, INT_MAX, NULL);
}
Expand Down

0 comments on commit 5794e51

Please sign in to comment.