summaryrefslogtreecommitdiff
path: root/libunwindstack/tests/MemoryFileTest.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2017-06-29 16:18:08 -0700
committerTom Cherry <tomcherry@google.com>2017-06-30 13:52:48 -0700
commit8d13d808a5634701c55276796683857ac2d5c99a (patch)
tree290e7ff26357de3fc98a6bbbc56cc17d57c57a79 /libunwindstack/tests/MemoryFileTest.cpp
parentc70bf5836c1d6b734af270ed7b3b8a9b425b83b9 (diff)
init: reap zombies only after kill(-pid, ...)
When init gets SIGCHLD, it uses waitpid() to get the pid of an exited process. It then calls kill(-pid, ...) to ensure that all processes in the process group started by that process are killed as well. There is a bug here however as waitpid() reaps the pid when it returns, meaning that the call to kill(-pid, ...) may fail with ESRCH as there are no remaining references to that pid. Or worse, if the pid is reused, the wrong processes may get the signal. This fixes the bug by using waitid() with WNOWAIT to get the pid of an exited process, which does not reap the pid. It then uses waitpid() with the returned pid to do the reap only after the above kill(-pid, ...) and other operations have completed. Bug: 38164998 Test: kill surfaceflinger and see that processes exit and are reaped appropriately Test: `adb reboot` and observe that the extraneous kill() failed messages do not appear Change-Id: Ic0213e1c97e0141e6c13129dc2abbfed86de138b
Diffstat (limited to 'libunwindstack/tests/MemoryFileTest.cpp')
0 files changed, 0 insertions, 0 deletions