libminijail: Set the controlling tty if appropriate. am: f486e262fa am: c4dbc7cde8 am: e564e85bec

Original change: https://android-review.googlesource.com/c/platform/external/minijail/+/2032023

Change-Id: I35eeec3647aa5c326a3f8b86e7a4fb5ed5f94e77
diff --git a/libminijail.c b/libminijail.c
index ea59404..aab1294 100644
--- a/libminijail.c
+++ b/libminijail.c
@@ -2889,6 +2889,12 @@
 		if (setsid() < 0) {
 			pdie("setsid() failed");
 		}
+
+		if (isatty(STDIN_FILENO)) {
+			if (ioctl(STDIN_FILENO, TIOCSCTTY, 0) != 0) {
+				pwarn("failed to set controlling terminal");
+			}
+		}
 	}
 }
 
@@ -2943,12 +2949,12 @@
 			 char *const argv[], char *const envp[])
 {
 	struct minijail_run_config config = {
-	   .filename = filename,
-	   .elf_fd = -1,
-	   .argv = argv,
-	   .envp = envp,
-	   .use_preload = true,
-	   .exec_in_child = true,
+	    .filename = filename,
+	    .elf_fd = -1,
+	    .argv = argv,
+	    .envp = envp,
+	    .use_preload = true,
+	    .exec_in_child = true,
 	};
 	return minijail_run_config_internal(j, &config);
 }