Skip to content

Commit

Permalink
init: become session leader
Browse files Browse the repository at this point in the history
Before exec()ing we need to become session leader otherwise some shells will
not be able to correctly initialize job control.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Oct 10, 2017
1 parent 7c8f5d1 commit f6d9b7d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lxc/tools/lxc_init.c
Expand Up @@ -77,7 +77,7 @@ static void usage(void) {

int main(int argc, char *argv[])
{
pid_t pid;
pid_t pid, sid;
int err;
char **aargv;
sigset_t mask, omask;
Expand Down Expand Up @@ -189,6 +189,10 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

sid = setsid();
if (sid < 0)
DEBUG("Failed to make child session leader");

NOTICE("About to exec '%s'", aargv[0]);

ret = execvp(aargv[0], aargv);
Expand Down

0 comments on commit f6d9b7d

Please sign in to comment.