From 2113caeae7576a9207d65a86afe87d151e3c496e Mon Sep 17 00:00:00 2001 From: Abhijeet Kaur Date: Fri, 13 Sep 2019 09:24:15 +0100 Subject: Set close-on-exec flag for bugreportz socket in dumpstate dumpstate triggers lshal child processes, bugreportz connection socket fd in dumpstate is passed on to these processes. Set close-on-exec flag allows to close the socket connection from dumpstate, even if child processes do not terminate. Test: `adb bugreport` `adb bugreport BR.zip` works as expected Bug: 140713872 Change-Id: I4aa07a60110da383110e2e9091c72403351ac3dc --- cmds/dumpstate/dumpstate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 693525ae68..73c66c248b 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -3504,7 +3504,7 @@ int open_socket(const char *service) { struct sockaddr addr; socklen_t alen = sizeof(addr); - int fd = accept(s, &addr, &alen); + int fd = accept4(s, &addr, &alen, SOCK_CLOEXEC); // Close socket just after accept(), to make sure that connect() by client will get error // when the socket is used by the other services. -- cgit v1.2.3-59-g8ed1b