summaryrefslogtreecommitdiffstats
path: root/init/service.h
diff options
context:
space:
mode:
authorBertrand SIMONNET <bsimonnet@google.com>2015-12-18 11:39:59 -0800
committerBertrand SIMONNET <bsimonnet@google.com>2016-01-08 11:12:15 -0800
commitb7e03e82b89a30b09fea88eaf2a5638df1017cf6 (patch)
tree4a82e891ea154a1ac42c736e120a1b8e985c5a06 /init/service.h
parenta649a7df15617e1e54cc89c2f682a5e6472bf304 (diff)
downloadcore-b7e03e82b89a30b09fea88eaf2a5638df1017cf6.tar.gz
core-b7e03e82b89a30b09fea88eaf2a5638df1017cf6.tar.bz2
core-b7e03e82b89a30b09fea88eaf2a5638df1017cf6.zip
init: Allows shutting down cleanly.
When ro.build.shutdown_timeout is set, init will send a SIGTERM signal to all services on reboot. The normal shutdown process will continue once all services have exited or after the shutdown timeout (ro.build.shutdown_timeout). If ro.build.shutdown_timeout is not set, we assume a 0s timeout. Bug: 26216447 Test: manual: Ask to reboot. All services exit cleanly. Change-Id: If921f6e8d87211e500ac9fa86f3e1eabe02d18cf
Diffstat (limited to 'init/service.h')
-rw-r--r--init/service.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/init/service.h b/init/service.h
index 10eb736cb..35abde9b7 100644
--- a/init/service.h
+++ b/init/service.h
@@ -82,6 +82,7 @@ public:
bool Enable();
void Reset();
void Stop();
+ void Terminate();
void Restart();
void RestartIfNeeded(time_t& process_needs_restart);
bool Reap();
@@ -167,17 +168,22 @@ public:
Service* FindServiceByName(const std::string& name) const;
Service* FindServiceByPid(pid_t pid) const;
Service* FindServiceByKeychord(int keychord_id) const;
- void ForEachService(void (*func)(Service* svc)) const;
+ void ForEachService(std::function<void(Service*)> callback) const;
void ForEachServiceInClass(const std::string& classname,
void (*func)(Service* svc)) const;
void ForEachServiceWithFlags(unsigned matchflags,
void (*func)(Service* svc)) const;
+ void ReapAnyOutstandingChildren();
void RemoveService(const Service& svc);
void DumpState() const;
private:
ServiceManager();
+ // Cleans up a child process that exited.
+ // Returns true iff a children was cleaned up.
+ bool ReapOneProcess();
+
static int exec_count_; // Every service needs a unique name.
std::vector<std::unique_ptr<Service>> services_;
};