No description
013289364e
Opening child_ptty before fork() means that the parent process will use child_ptty as the controlling terminal if it doesn't already have one. This is a problem, because when the parent_ptty closes, SIGHUP will be sent to the parent process, since its controlling terminal has closed. It's better to have the child process start its own session and then open child_ptty as its controlling terminal. In this case, the child process will get SIGHUP if the parent process exits, but the parent process avoids the original issue. There is a concern that the child_ptty will never be opened and POLLHUP will never be generated, but there is a work-around in place with a timeout to handle that extremely rare situation. Secondly, remove the ignore_int_quit logic. It is described to totally ignore these signals, similar to `nohup` which should be preferred. However, it regressed shortly after being introduced in 2013 and serves essentially no purpose currently. Thirdly, add a forward_signals option that does what we should have done the whole time with signals: it forwards SIGHUP, SIGQUIT, and SIGINT to the child process and let that process handle them. This only needs to be enabled in the `logwrapper` case itself. Other processes should not need to change any signals. This fixes case 3) below. Lastly, add O_CLOEXEC where appropriate. Test: launch process as `adb shell logwrapper yes` 1) The both processes exit when given SIGINT 2) The process prints when abbreviated is not enabled 3) The process does print when abbreviated is enabled; this was previously broken Test: launch process as `adb shell` then `logwrapper yes` 4) The both processes exit when given SIGINT 5) The process prints if abbreviated is enabled or not. 6) Ctrl-c then Ctrl-c again rapidly and observe that the logwrapper process is terminated by the second Ctrl-c. Test: simulate a failure in child() before opening child_tty and observe logwrapper and the child exiting appropriately. Change-Id: Ia76cd17e16535500170d8f5e2183b3bbbf843df7 |
||
---|---|---|
adb | ||
base | ||
bootstat | ||
cpio | ||
debuggerd | ||
deprecated-adf | ||
diagnose_usb | ||
fastboot | ||
fs_mgr | ||
gatekeeperd | ||
healthd | ||
include | ||
init | ||
janitors | ||
libappfuse | ||
libasyncio | ||
libbacktrace | ||
libbinderwrapper | ||
libcrypto_utils | ||
libcutils | ||
libdiskconfig | ||
libgrallocusage | ||
libion | ||
libkeyutils | ||
liblog | ||
libmeminfo | ||
libmemtrack | ||
libmemunreachable | ||
libmetricslogger | ||
libmodprobe | ||
libnativebridge | ||
libnativeloader | ||
libnetutils | ||
libpackagelistparser | ||
libpixelflinger | ||
libprocessgroup | ||
libprocinfo | ||
libqtaguid | ||
libsparse | ||
libstats | ||
libsuspend | ||
libsync | ||
libsystem | ||
libsysutils | ||
libunwindstack | ||
libusbhost | ||
libutils | ||
libvndksupport | ||
libziparchive | ||
llkd | ||
lmkd | ||
logcat | ||
logd | ||
logwrapper | ||
property_service | ||
qemu_pipe | ||
reboot | ||
rootdir | ||
run-as | ||
sdcard | ||
shell_and_utilities | ||
storaged | ||
toolbox | ||
trusty | ||
usbd | ||
watchdogd | ||
.clang-format | ||
.clang-format-2 | ||
.clang-format-4 | ||
.gitignore | ||
Android.bp | ||
CleanSpec.mk | ||
MODULE_LICENSE_APACHE2 | ||
NOTICE | ||
OWNERS | ||
PREUPLOAD.cfg | ||
TEST_MAPPING |