Merge "Ignore setsid error in some cases." am: 3562fd0fa8 am: 324acdce69
am: f7756b89e9
Change-Id: I7bc3c1f46fec39fb8fd2fe597633b067ad0a8bda
diff --git a/adb/client/main.cpp b/adb/client/main.cpp
index 279bb70..4ec0fc2 100644
--- a/adb/client/main.cpp
+++ b/adb/client/main.cpp
@@ -129,7 +129,9 @@
// Start a new session for the daemon. Do this here instead of after the fork so
// that a ctrl-c between the "starting server" and "done starting server" messages
// gets a chance to terminate the server.
- if (setsid() == -1) {
+ // setsid will fail with EPERM if it's already been a lead process of new session.
+ // Ignore such error.
+ if (setsid() == -1 && errno != EPERM) {
fatal("setsid() failed: %s", strerror(errno));
}
#endif