freebsd-dev/bin/pwait
Alexander V. Chernikov 5bdce6ff54 Remove deadlock in rc caused by pwait waiting for itself.
The following situation can trigger the deadlock:
1) Long time ago a_service was started through rc.d
2) We want to restart a_service and issue service a_service restart
3) rc.subr reads current process PID (via file or process),
   sends TERM signal and runs pwait with PID harvested
4) a_service process dies very quickly so it's PID becomes available.
   It is possible that while original process was running,
   PID counter overflowed and pwait got assigned a_service's PID.

This patch ignores pid(s) to wait that are equal to pwait PID.

Reported by:	Dan McGregor, Boris Lytochkin
Submitted by:	Boris Lytochkin <lytboris at gmail.com>
Reviewed By:	0mp
MFC after:	2 weeks
PR:		218598
Differential Revision: https://reviews.freebsd.org/D28240
2021-01-21 21:36:37 +00:00
..
tests Implement tests for the newly added -o flag. 2020-01-26 11:03:45 +00:00
Makefile Add HAS_TESTS to all Makefiles that use the SUBDIR.${MK_TESTS}+= tests idiom 2017-08-02 08:14:06 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
pwait.1 Remove deadlock in rc caused by pwait waiting for itself. 2021-01-21 21:36:37 +00:00
pwait.c Remove deadlock in rc caused by pwait waiting for itself. 2021-01-21 21:36:37 +00:00