summaryrefslogtreecommitdiff
path: root/init/sigchld_handler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* init: Add diagnostics for signalfd epoll failures.David Anderson2022-03-081-1/+4
| | | | | | | | Bug: 222441619 Test: inject failure with close, check for log messages Change-Id: Ia18b88841779e230d00a6c47aaed4952b1444f85 (cherry picked from commit 0fa7c40c4cf1597dd0cca1f60b5eef8fdf6168a3) Merged-In: Ia18b88841779e230d00a6c47aaed4952b1444f85
* Revert "init: handle property service callbacks asynchronously"Tom Cherry2020-03-101-2/+0
| | | | | | | | | | This is apparently causing problems with reboot. This reverts commit 7205c6293341c82701e849fa29cfab66916d1052. Bug: 150863651 Test: build Change-Id: Ib8a4835cdc8358a54c7acdebc5c95038963a0419
* init: handle property service callbacks asynchronouslyTom Cherry2020-02-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous change moved property_service into its own thread, since there was otherwise a deadlock whenever a process called by init would try to set a property. This new thread, however, would send a message via a blocking socket to init for each property that it received, since init may need to take action depending on which property it is. Unfortunately, this means that the deadlock is still possible, the only difference is the socket's buffer must be filled before init deadlocks. There are possible partial solutions here: the socket's buffer may be increased or property_service may only send messages for the properties that init will take action on, however all of these solutions still lead to eventual deadlock. The only complete solution is to handle these messages asynchronously. This change, therefore, adds the following: 1) A lock for instructing init to reboot 2) A lock for waiting on properties 3) A lock for queueing new properties 4) A lock for any actions with ServiceList or any Services, enforced through thread annotations, particularly since this code was not designed with the intention of being multi-threaded. Bug: 146877356 Bug: 148236233 Test: boot Test: kill hwservicemanager without deadlock Change-Id: I84108e54217866205a48c45e8b59355012c32ea8
* userspace reboot: stop post-data services and wait for them to be killedNikita Ioffe2019-10-101-7/+30
| | | | | | | | | | | | | | | * Refactored code around stopping services a little bit to reuse it between full reboot and userspace reboot. * Add a scope_guard to fallback to full reboot in case userspace reboot fails. * In case of userspace reboot init will also wait for services to be terminated/killed and log the ones that didn't react to SIGTERM/SIGKILL in time. * If some of the services didn't react to SIGKILL, fail userspace reboot. Test: adb reboot userspace Bug: 135984674 Change-Id: I820c7bc406169333b0f929f0eea028d8384eb2ac
* init: add timing log for oneshot and exec_background servicesWei Wang2019-07-311-0/+7
| | | | | | | Bug: 136523746 Bug: 138732985 Test: boot Change-Id: I713edd2ba8a391d5afbea796c6d58ffac9477436
* Split out ServiceList and ServiceParser from service.cpp/.hTom Cherry2019-06-261-0/+1
| | | | | | | These always should have been in their own files. Test: build Change-Id: I201109b5ee63016e78901bbfd404846d45e1d4e6
* init: simplify async restoreconTom Cherry2019-04-241-4/+1
| | | | | | | | | | | | | | | | | | | In the future, property service may run in its own thread or process, which means that PropertyChildReap() needs to be refactored to not run as part of the init signal handler. The new method spawns a new thread that handles the queue of paths that require restorecon. It then communicates back to property service via android::base::SetProperty(). Property service distinguishes the thread from other callers of SetProperty() by checking the pid in the credentials for the socket connection, thus avoiding dependencies on the rest of init. The new method also drops the genericness, since restorecon is the only function that we should ever need to run asynchronously Test: async restorecon works, including with queued requests Change-Id: I2ca00459969e77b1820776dac23d0a0d974e330b
* Re-land "If enablefilecrypto or init_user0 fails, reboot into recovery."Paul Crowley2018-04-171-6/+5
| | | | | | | | | An earlier such change was reverted in commit e242a97db547dc73efea1b5287536be66637dc33. Bug: 70487538 Test: ensure that angler can boot Merged-In: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0 Change-Id: Id5f57fce1c9b817a2650e0c848143d8a0d286bf0
* init: use signalfd to catch SIGCHLDRyan Prichard2018-04-121-39/+0
| | | | | | | | | | | Previously, if init received too many SIGCHLD signals, then the write to signal_write_fd could fail with EAGAIN. The handler tried to log the EAGAIN error, and init deadlocked if the interrupted init process had already acquired a logging-related lock. Bug: b/77867680 Test: manual Change-Id: Ief0b5e94d8517827a5a7d03773391ba3ba9447c4
* Revert "If enablefilecrypto or init_user0 fails, reboot into recovery."Paul Crowley2018-03-011-5/+6
| | | | | | | | | | This reverts commit 959b05553576ffc15da4334a5917ce763611ab82. Reason for revert: b/73968735 Bug: 73968735 Test: b/73968735#comment5 Change-Id: Ifce4c029bab7380c60e20cc2b2885beb4a097456
* If enablefilecrypto or init_user0 fails, reboot into recovery.Paul Crowley2018-02-151-6/+5
| | | | | | Test: Roll back PLATFORM_SECURITY_PATCH, ensure recovery dialog is seen Bug: 70487538 Change-Id: Iceb6af3f9d6aea6bc646dbb4b5d29dffcb284736
* init: run vendor commands in a separate SELinux contextTom Cherry2017-09-291-13/+19
| | | | | | | | | | | | | | | | | | | | | | One of the major aspects of treble is the compartmentalization of system and vendor components, however init leaves a huge gap here, as vendor init scripts run in the same context as system init scripts and thus can access and modify the same properties, files, etc as the system can. This change is meant to close that gap. It forks a separate 'subcontext' init that runs in a different SELinux context with permissions that match what vendors should have access to. Commands get sent over a socket to this 'subcontext' init that then runs them in this SELinux context and returns the result. Note that not all commands run in the subcontext; some commands such as those dealing with services only make sense in the context of the main init process. Bug: 62875318 Test: init unit tests, boot bullhead, boot sailfish Change-Id: Idf4a4ebf98842d27b8627f901f961ab9eb412aee
* init: cleanup exit() usesTom Cherry2017-09-261-2/+1
| | | | | | | | | | | | | Primarily, this fixes a bug where a forked child of property service uses exit() instead of _exit, which has the unintended consequences of running the global destructors of init proper, which leads to unintended cleanup. Secondly, this replaces the remaining calls of exit() that really should be LOG(FATAL). Test: boot sailfish Change-Id: I779228e7d44a73186bc7685bb723c4b9278a0a2d
* init: Allow clean system shutdown upon SIGTERMLuis Hector Chavez2017-09-071-0/+142
This allows Android to cleanly shutdown when running in a PID namespace in a way that does not rely on adbd running. This is useful to allow Android to be running in a container and its lifetime managed by an OCI-compliant tool. Bug: 65415372 Test: `kill -TERM 1` as root is correctly dropped. Test: `kill -TERM 1` from the init PID namespace causes init to cleanly shutdown. Change-Id: Ia66ebdb436221919081bc4723337c0c7f1e53b09