No description
Find a file
Tom Cherry 8d13d808a5 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
2017-06-30 13:52:48 -07:00
adb Merge "Give a clear error message if we can't start the server." 2017-06-21 00:48:30 +00:00
adf libadfhwc: Fix adf_hwc_close 2017-03-02 17:40:16 +00:00
base logging: make LOG(FATAL) always run with the static analyzer. 2017-05-31 14:41:22 +00:00
bootstat bootstat: Log factory_reset_boot_complete separately from ota_*. 2017-05-30 15:03:15 -07:00
cpio Possible null pointer miss on realloc 2017-03-23 22:41:14 +01:00
debuggerd Merge "tombstoned: Improve message on java trace completion." 2017-06-23 08:12:51 +00:00
demangle Mark libdemangle as vendor_available 2017-06-14 18:58:22 +09:00
fastboot fastboot: use filename instead of fd to generate filesystem image 2017-05-31 21:23:12 +00:00
fingerprintd fingerprint: bump hw api version to 2.1 [DO NOT MERGE] 2017-01-27 22:11:15 +00:00
fs_mgr AVB: allow no metadata in the generic system.img for project Treble 2017-06-24 09:20:15 +08:00
gatekeeperd Merge "liblog: use log/log.h when utilizing ALOG macros" am: 01e12b4ee7 am: c3b346ea93 2017-01-11 19:26:19 +00:00
healthd healthd: add battery health status values from JEITA spec 2017-06-20 18:08:51 -07:00
include Add libziparchive-based unzip. 2017-06-04 11:53:48 -07:00
init init: reap zombies only after kill(-pid, ...) 2017-06-30 13:52:48 -07:00
libappfuse Add test config to libappfuse_test 2017-03-31 17:11:50 -07:00
libbacktrace Use demangle for function names. 2017-06-02 10:10:24 -07:00
libbinderwrapper libbinderwrapper: Android.mk -> Android.bp 2017-04-25 15:55:26 -07:00
libcrypto_utils Rely on the platform -std default. 2016-10-10 14:31:12 -07:00
libcutils libcutils: Clarify schedboost_enabled() 2017-06-16 21:30:49 +00:00
libdiskconfig Mark libdiskconfig vendor_available. 2017-05-24 14:21:48 -07:00
libion Mark libion vendor_available. 2017-05-24 14:25:08 -07:00
libkeyutils Add libkeyutils. 2017-05-10 10:40:11 -07:00
liblog liblog: add bool to android_log_event_list 2017-06-05 07:50:13 -07:00
libmemtrack liblog: use log/log.h when utilizing ALOG macros 2017-01-11 09:31:15 -08:00
libmemunreachable Fix stack test on arm32 2017-06-22 14:21:52 -07:00
libmetricslogger Mark libmetricslogger vendor_available. 2017-05-24 14:13:51 -07:00
libnativebridge Load vendor public libraries to sphal namespace 2017-05-25 10:30:55 -07:00
libnativeloader Load vendor public libraries to sphal namespace 2017-05-25 10:30:55 -07:00
libnetutils Mark libnetutils vendor_available. 2017-05-24 14:18:35 -07:00
libpackagelistparser liblog: use log/log.h when utilizing ALOG macros 2017-01-11 09:31:15 -08:00
libpixelflinger Va_end should be used with va_start 2017-03-23 22:41:42 +01:00
libprocessgroup init: move killing of process groups to libprocessgroup 2017-06-07 13:20:21 -07:00
libprocinfo Mark libprocinfo vendor_avaialable. 2017-05-24 14:28:22 -07:00
libsparse libsparse: Fix odd-sized input files total_blks 2017-04-19 10:32:45 -05:00
libsuspend Mark libsuspend vendor_available. 2017-05-24 14:44:30 -07:00
libsync libsync: vendor_available 2017-04-19 10:32:51 -07:00
libsystem libutils: export system_headers 2017-04-28 09:42:50 +09:00
libsysutils libsysutils: Fix vold vulnerability in FrameworkListener 2017-06-20 06:32:11 +00:00
libunwindstack Add section parsing and function name handling. 2017-06-23 10:51:28 -07:00
libusbhost Convert libusbhost to Android.bp 2017-04-20 08:37:12 -07:00
libutils Merge "Va_end should be used with va_start" 2017-06-14 23:00:42 +00:00
libziparchive Merge "zip_archive_test: compare error codes directly." 2017-06-20 10:50:27 +00:00
lmkd lmkd: Android.mk -> Android.bp 2017-04-28 15:20:18 -07:00
logcat logcat: logcatd: make logcatd killable 2017-05-31 11:27:22 -07:00
logd logd-unit-tests: make sure use unsigned types when reading le 2017-06-16 17:45:37 +09:00
logwrapper Merge "logwrapper: add a benchmark for android_fork_execvp_ext" 2017-03-23 11:56:10 +00:00
mkbootimg mkbootimg: use int for os_version and os_patch_level 2016-03-29 16:06:37 -07:00
reboot Convert more Android.mk files to Android.bp 2016-07-13 17:41:45 -07:00
rootdir cgroups used by init must be mounted before any services start 2017-05-31 16:12:23 -07:00
run-as Define range of GIDs for cached app data. 2016-12-13 13:28:08 -07:00
sdcard Merge "Switch sdcardfs over to bind mounts." 2016-11-30 05:20:40 +00:00
shell_and_utilities Add building and installing of grep for vendor. 2017-06-15 15:04:41 -07:00
toolbox Merge "Add building and installing of grep for vendor." 2017-06-16 23:24:32 +00:00
trusty trusty*: Android.mk -> Android.bp 2017-05-08 16:54:04 +00:00
.clang-format Add a 2 width option of clang format. 2017-03-10 13:01:39 -08:00
.clang-format-2 Only allow short functions in class definitions. 2017-03-28 12:31:37 -07:00
.clang-format-4 Only allow short functions in class definitions. 2017-03-28 12:31:37 -07:00
.gitignore Ignore adb/*.pyc files 2015-08-11 12:59:58 -07:00
Android.bp Export android_filesystem_config.h as a filegroup 2017-01-17 18:20:28 -08:00
Android.mk Remove the simulator target from all makefiles. 2011-07-11 22:12:32 -07:00
CleanSpec.mk init.rc: have hwservicemanager start the HAL class 2016-09-26 00:23:51 -07:00
MODULE_LICENSE_APACHE2 auto import from //depot/cupcake/@135843 2013-07-30 13:56:49 -07:00
NOTICE Fix omission in NOTICE file. 2013-07-30 13:56:55 -07:00
platform_tools_tool_version.mk Fix warning on the build servers 2017-05-25 12:35:40 -07:00
PREUPLOAD.cfg Add a PREUPLOAD.cfg file to run git-clang-format on every commit 2017-03-08 16:51:26 +08:00