From ac8b5bd0bc7f48ae7fe6156f8a20732f696ea143 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 2 Nov 2023 12:55:46 -0700 Subject: [PATCH 1/3] init: Fix a compiler warning Fix the following compiler warning: system/core/init/init.cpp:754:57: warning: ISO C++ requires field designators to be specified in declaration order; field '' will be initialized after field 'sa_flags' [-Wreorder-init-list] const struct sigaction act { .sa_handler = SIG_DFL, .sa_flags = SA_NOCLDSTOP }; ^~~~~~~~~~~~~~~~~~~~~~~~ system/core/init/init.cpp:754:34: note: previous initialization for field '' is here const struct sigaction act { .sa_handler = SIG_DFL, .sa_flags = SA_NOCLDSTOP }; ^~~~~~~~~~~~~~~~~~~~~ Change-Id: I29e2d51dfdff85212a33eebfd51b241268cdfe9a Signed-off-by: Bart Van Assche --- init/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/init.cpp b/init/init.cpp index 40e21696f..19f34dabb 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -751,7 +751,7 @@ static void UnblockSignals() { static void InstallSignalFdHandler(Epoll* epoll) { // Applying SA_NOCLDSTOP to a defaulted SIGCHLD handler prevents the signalfd from receiving // SIGCHLD when a child process stops or continues (b/77867680#comment9). - const struct sigaction act { .sa_handler = SIG_DFL, .sa_flags = SA_NOCLDSTOP }; + const struct sigaction act { .sa_flags = SA_NOCLDSTOP, .sa_handler = SIG_DFL }; sigaction(SIGCHLD, &act, nullptr); sigset_t mask; From 4844092066bb4e849d7dff3675d4d4a306df9b33 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 2 Nov 2023 13:02:57 -0700 Subject: [PATCH 2/3] init/host_init_verifier: Fix a compiler warning Fix the following compiler warning: //system/core/init:host_init_verifier clang++ host_init_verifier.cp system/core/init/host_init_verifier.cpp:112:9: warning: ISO C++ requires field designators to be specified in declaration order; field 'pw_shell' will be initialized after field 'pw_uid' [-Wreorder-init-list] .pw_uid = 0, ^~~~~~~~~~~ system/core/init/host_init_verifier.cpp:111:21: note: previous initialization for field 'pw_shell' is here .pw_shell = static_shell, ^~~~~~~~~~~~ Change-Id: I930c668d7fb1d12ebe9307b1549776da71a9a95a Signed-off-by: Bart Van Assche --- init/host_init_verifier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/host_init_verifier.cpp b/init/host_init_verifier.cpp index f070776ec..662185c44 100644 --- a/init/host_init_verifier.cpp +++ b/init/host_init_verifier.cpp @@ -108,9 +108,9 @@ passwd* getpwnam(const char* login) { // NOLINT: implementing bad function. static passwd static_passwd = { .pw_name = static_name, .pw_dir = static_dir, - .pw_shell = static_shell, .pw_uid = 0, .pw_gid = 0, + .pw_shell = static_shell, }; for (size_t n = 0; n < android_id_count; ++n) { From 7ce6453aa8eda688580f3a28e260554ce930d96f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 1 Nov 2023 14:29:07 -0700 Subject: [PATCH 3/3] init: Fix a bug in the WaitToBeReaped() logging code Only report status information for the processes that are still running. Additionally, make the logging output look better by starting the process information from /proc start on a new line. Fixes: ea595ba2a05a ("init: Log more information if stopping times out") Change-Id: I3c882c364f11278087a78efb7a8e8fee8e582417 Signed-off-by: Bart Van Assche --- init/sigchld_handler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/sigchld_handler.cpp b/init/sigchld_handler.cpp index f8c501f8a..0901a960f 100644 --- a/init/sigchld_handler.cpp +++ b/init/sigchld_handler.cpp @@ -139,10 +139,10 @@ void WaitToBeReaped(const std::vector& pids, std::chrono::milliseconds ti } LOG(INFO) << "Waiting for " << pids.size() << " pids to be reaped took " << t << " with " << alive_pids.size() << " of them still running"; - for (pid_t pid : pids) { + for (pid_t pid : alive_pids) { std::string status = "(no-such-pid)"; ReadFileToString(StringPrintf("/proc/%d/status", pid), &status); - LOG(INFO) << "Still running: " << pid << ' ' << status; + LOG(INFO) << "Still running: " << pid << '\n' << status; } }