From c9bc6bb4364231180897169bdd4bed0836480f7f Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Tue, 24 Nov 2020 11:34:40 -0800 Subject: [PATCH] init: add some documentation in service_utils.h Test: n/a Change-Id: I2a2691a6d1f643e255550498d9871e38f1b51efa --- init/service_utils.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init/service_utils.h b/init/service_utils.h index e74f8c17e..1e0b4bd2b 100644 --- a/init/service_utils.h +++ b/init/service_utils.h @@ -37,6 +37,8 @@ class Descriptor { Descriptor(const std::string& name, android::base::unique_fd fd) : name_(name), fd_(std::move(fd)){}; + // Publish() unsets FD_CLOEXEC from the FD and publishes its name via setenv(). It should be + // called when starting a service after fork() and before exec(). void Publish() const; private: @@ -53,6 +55,9 @@ struct SocketDescriptor { std::string context; bool passcred = false; + // Create() creates the named unix domain socket in /dev/socket and returns a Descriptor object. + // It should be called when starting a service, before calling fork(), such that the socket is + // synchronously created before starting any other services, which may depend on it. Result Create(const std::string& global_context) const; };