Set a separate session/process_group
authorRobert Swiecki <swiecki@google.com>
Tue, 24 Nov 2015 17:34:05 +0000 (18:34 +0100)
committerRobert Swiecki <swiecki@google.com>
Tue, 24 Nov 2015 17:34:05 +0000 (18:34 +0100)
contain.c
subproc.c

index 7a90ea8e57c302210ec8ae52f7525780ae448374..54fa2ab10484cdd2875d97bc10daa290466f7289 100644 (file)
--- a/contain.c
+++ b/contain.c
@@ -179,6 +179,7 @@ bool containPrepareEnv(struct nsjconf_t * nsjconf)
        if (setpriority(PRIO_PROCESS, 0, 19) == -1 && errno != 0) {
                PLOG_W("setpriority(19)");
        }
+       setsid();
        return true;
 }
 
@@ -267,7 +268,7 @@ bool containMountFS(struct nsjconf_t * nsjconf)
                PLOG_E("CHROOT('/new_root')");
                return false;
        }
-       
+
        if (chdir(nsjconf->cwd) == -1) {
                PLOG_E("chdir('%s')", nsjconf->cwd);
                return false;
index 542ae4787dbcce3ee43376eba65be26741af5f46..c84d2feb861e2250720451f10b06782f4e61d6da 100644 (file)
--- a/subproc.c
+++ b/subproc.c
@@ -238,7 +238,7 @@ void subprocRunChild(struct nsjconf_t *nsjconf, int fd_in, int fd_out, int fd_er
                return;
        }
 
-       pid_t pid = syscall(__NR_clone, (uintptr_t)flags, NULL, NULL, NULL, (uintptr_t)0);
+       pid_t pid = syscall(__NR_clone, (uintptr_t) flags, NULL, NULL, NULL, (uintptr_t) 0);
        if (pid == 0) {
                subprocNewProc(nsjconf, fd_in, fd_out, fd_err, pipefd[1]);
        }