Skip to content

Commit fb208d3

Browse files
committed
revoke_pty: use killpg() not kill() to send HUP to the process group
Also make sure we never call killpg(-1, SIGHUP), which would send SIGHUP to process 1 (init). It is possible for cmnd_pid to be -1 in certain error conditions where sudo killed the command itself. This may explain GitHub issue #458.
1 parent e5d953f commit fb208d3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/exec_pty.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,11 @@ revoke_pty(struct exec_closure *ec)
358358
pgrp = tcpgrp;
359359
close(io_fds[SFD_LEADER]);
360360
}
361-
sudo_debug_printf(SUDO_DEBUG_NOTICE, "%s: killpg(%d, SIGHUP)",
362-
__func__, (int)pgrp);
363-
kill(pgrp, SIGHUP);
361+
if (pgrp != -1) {
362+
sudo_debug_printf(SUDO_DEBUG_NOTICE, "%s: killpg(%d, SIGHUP)",
363+
__func__, (int)pgrp);
364+
killpg(pgrp, SIGHUP);
365+
}
364366
}
365367

366368
/*

0 commit comments

Comments
 (0)