Bug 784

Summary: sudo returns exit code 0 after process is killed with SIGTERM
Product: Sudo Reporter: Timothy Palpant <tim>
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: normal CC: vlee
Priority: low    
Version: 1.8.16   
Hardware: PC   
OS: Linux   

Description Timothy Palpant 2017-04-26 17:46:55 MDT
I've noticed that sudo returns 0, not the exit value of the command, if the process being run is killed by SIGTERM. A minimal example is:

$ sleep 300; echo $?
Terminated
143

$ sudo sleep 300; echo $?
0

where each of these is killed by running `sudo pkill sleep` in another terminal. This behavior seems to have changed since sudo 1.8.3 on Ubuntu 12.04, which prints 143 in both cases. Is this expected behavior? It is difficult to discern if the underlying process was terminated prematurely.

$ sudo --version
Sudo version 1.8.16
Sudoers policy plugin version 1.8.16
Sudoers file grammar version 45
Sudoers I/O plugin version 1.8.16

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"

$ uname -a
Linux palpant-dbx 4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Comment 1 Todd C. Miller 2017-04-26 20:18:36 MDT
Yes, that's a bug, it was introduced by the fix for bug #722.
This is fixed by https://www.sudo.ws/repos/sudo/rev/50b988d0c97f

The fix will be included in sudo 1.8.20.
Comment 2 Todd C. Miller 2017-05-10 10:34:21 MDT
Fixed in sudo 1.8.20, available now.