Switch the listening select loop from select() to pselect() and
authordtucker <dtucker@openbsd.org>
Fri, 4 Jun 2021 05:09:08 +0000 (05:09 +0000)
committerdtucker <dtucker@openbsd.org>
Fri, 4 Jun 2021 05:09:08 +0000 (05:09 +0000)
commita7f01d8509d613d095361decbe98dd94a11d9b6b
treea63fa69d02268c53de27883e1fc4ea8cbdecd1b8
parent1025d804ea594740ac60e3b0779bc2bc35c957e8
Switch the listening select loop from select() to pselect() and
mask signals while checking signal flags, umasking for pselect and
restoring afterwards. Also restore signals before sighup_restart
so they don't remain blocked after restart.

This prevents a race where a SIGTERM or SIGHUP can arrive between
checking the flag and calling select (eg if sshd is processing a
new connection) resulting in sshd not shutting down until the next
time it receives a new connection.  bz#2158, with & ok djm@
usr.bin/ssh/sshd.c