From d394f74365a5c8f235c928d4e003551f36164577 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Nov 2022 09:45:33 -0800 Subject: [PATCH] init: Reduce the number of system calls Change setpgid(0, getpid()) into setpgid(0, 0). This patch removes one system call but does not change the behavior of the code. From the setpgid() man page: "If pgid is zero, then the PGID of the process specified by pid is made the same as its process ID." Bug: 213617178 Change-Id: I7031d9eb3711f526751da495c07a8927f9386d97 Signed-off-by: Bart Van Assche --- init/service_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/service_utils.cpp b/init/service_utils.cpp index a14969e98..52e66153c 100644 --- a/init/service_utils.cpp +++ b/init/service_utils.cpp @@ -244,7 +244,7 @@ Result SetProcessAttributes(const ProcessAttributes& attr) { setsid(); OpenConsole(attr.console); } else { - if (setpgid(0, getpid()) == -1) { + if (setpgid(0, 0) == -1) { return ErrnoError() << "setpgid failed"; } SetupStdio(attr.stdio_to_kmsg);