[sudo-users] Sudo ignoring SIGTERM unless connected to strace

Knut Aksel Røysland knutroy at ifi.uio.no
Sat Nov 5 17:44:16 MDT 2022


Hi,

I am trying to understand how I can get Sudo to handle SIGTERM in the following scenario:

  #!/usr/bin/bash
  set -x
  sudo -n sleep infinity &
  jobs
  sleep 5
  jobs -p | sudo -n xargs -r kill -TERM
  wait

What I am observing is that SIGTERM is ignored, so that "wait" hangs forever.

I discovered that if I connect strace to the Sudo process during the 5 seconds before SIGTERM is sent, using:

  sudo strace -p $(pidof sudo)

in a different terminal, then Sudo behaves as expected.

This makes me feel my Bash script is fine, but something surprising is going on inside Sudo.

System information:
  Sudo 1.9.12rc3
  Ubuntu 20.04
  Linux 5.4.0-131-generic

I hope someone here can help me understand what is going on, and help me get to the behavior I want without needing strace.

-- 
Regards,
Knut Aksel Røysland


More information about the sudo-users mailing list