Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8fab89f authored by Tao Wu's avatar Tao Wu
Browse files

Ignore setsid error in some cases.



If the calling process has already been a leading process of session.
setsid just fail with EPERM, ignore such error.

Test: killall adb;exec 3>f;adb fork-server server --reply-fd 3 & cat f
Change-Id: I1aeac079f29e10aa63ed724b5a43663f25c25ad5
Signed-off-by: default avatarTao Wu <lepton@google.com>
parent 41595685
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -129,7 +129,9 @@ int adb_server_main(int is_daemon, const std::string& socket_spec, int ack_reply
        // 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