Launcher checks for being session leader

Before requesting to create new process group the laucher checks it's
not the session leader.

Bug: 111794766
Test: local
Change-Id: Ib3cdefa760b00579d35bc473cd283aeab3b23703
diff --git a/host/commands/launch/main.cc b/host/commands/launch/main.cc
index ad910d2..df3b3c5 100644
--- a/host/commands/launch/main.cc
+++ b/host/commands/launch/main.cc
@@ -792,10 +792,12 @@
   } else {
     // Make sure the launcher runs in its own process group even when running in
     // foreground
-    int retval = setpgid(0, 0);
-    if (retval) {
-      LOG(ERROR) << "Failed to create new process group: " << strerror(errno);
-      std::exit(LauncherExitCodes::kProcessGroupError);
+    if (getsid(0) != getpid()) {
+      int retval = setpgid(0, 0);
+      if (retval) {
+        LOG(ERROR) << "Failed to create new process group: " << strerror(errno);
+        std::exit(LauncherExitCodes::kProcessGroupError);
+      }
     }
   }