send SIGTERM only once
- Processes capturing SIGTERM signal will not terminate and
killProcessGroup will timeout after retry. This gives 200ms
of waiting per such process. Change it to retry only once as
SIGTERM will keep failing for such process.
bug: 36696408
Test: check time spent in SIGTERM for reboot
(cherry picked from commit 506cb020c8ab080a6765b8300c84d751557ef744)
Change-Id: If080ae3aa00f1614b25cc3f673eeb70c9713ef6e
diff --git a/init/service.cpp b/init/service.cpp
index ede6364..3db34db 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -211,7 +211,13 @@
LOG(INFO) << "Sending signal " << signal
<< " to service '" << name_
<< "' (pid " << pid_ << ") process group...";
- if (killProcessGroup(uid_, pid_, signal) == -1) {
+ int r;
+ if (signal == SIGTERM) {
+ r = killProcessGroupOnce(uid_, pid_, signal);
+ } else {
+ r = killProcessGroup(uid_, pid_, signal);
+ }
+ if (r == -1) {
PLOG(ERROR) << "killProcessGroup(" << uid_ << ", " << pid_ << ", " << signal << ") failed";
}
if (kill(-pid_, signal) == -1) {