]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
truss(1): detach more carefully
authorKonstantin Belousov <kib@FreeBSD.org>
Wed, 12 Jan 2022 08:21:19 +0000 (10:21 +0200)
committerKonstantin Belousov <kib@FreeBSD.org>
Wed, 12 Jan 2022 18:04:41 +0000 (20:04 +0200)
commit12f747e6ff675edfc1f2f95f7fc435dc01e0c29c
tree77e5a39679b4266053ea553fde3437947121c7df
parentba33c288488d4543d1a140cd5c44b8b3c4c29915
truss(1): detach more carefully

When detaching, truss(1) sends SIGSTOP to the traced process to ensure
that it is detaching in the steady state.  But it is possible, for
multithreaded process, that wait() call returns event other than our
SIGSTOP notification.  As result, SIGSTOP might sit in some thread'
sigqueue, which makes SIGCONT a nop.  Then, the process is stopped when
the queued SIGSTOP is acted upon.

To handle this, loop until we drain everything before SIGSTOP,
and see that the process is stopped.

Note that the earlier fix makes it safe to have some more debugging
events longering after SIGSTOP is acted upon.  They will be ignored
after PT_DETACH.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33861
usr.bin/truss/setup.c