371
|
1 /* vi: set sw=4 ts=4:
|
|
2 *
|
|
3 * setsid.c - Run program in a new session ID.
|
|
4 *
|
|
5 * Copyright 2006 Rob Landley <rob@landley.net>
|
|
6
|
|
7 USE_SETSID(NEWTOY(setsid, "^<1t", TOYFLAG_USR|TOYFLAG_BIN))
|
|
8
|
|
9 config SETSID
|
|
10 bool "setsid"
|
|
11 default y
|
|
12 help
|
|
13 usage: setsid [-t] command [args...]
|
|
14
|
|
15 Run process in a new session.
|
|
16
|
|
17 -t Grab tty (become foreground process, receiving keyboard signals)
|
|
18 */
|
|
19
|
|
20 #include "toys.h"
|
|
21
|
|
22 void setsid_main(void)
|
|
23 {
|
|
24 while (setsid()<0)
|
|
25 if (vfork()) _exit(0);
|
|
26 if (toys.optflags) {
|
|
27 setpgid(0,0);
|
|
28 tcsetpgrp(0, getpid());
|
|
29 }
|
|
30 xexec(toys.optargs);
|
|
31 }
|