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
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 693525a..73c66c2 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -3504,7 +3504,7 @@
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.