comparison toys/setsid.c @ 371:2cec41ee6eea

Add setsid.
author Rob Landley <rob@landley.net>
date Tue, 05 Jan 2010 13:17:47 -0600
parents
children 878b94b32866
comparison
equal deleted inserted replaced
370:c7a26e26ad08 371:2cec41ee6eea
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 * Not in SUSv3.
8 * See http://www.opengroup.org/onlinepubs/009695399/utilities/
9
10 USE_SETSID(NEWTOY(setsid, "^<1t", TOYFLAG_USR|TOYFLAG_BIN))
11
12 config SETSID
13 bool "setsid"
14 default y
15 help
16 usage: setsid [-t] command [args...]
17
18 Run process in a new session.
19
20 -t Grab tty (become foreground process, receiving keyboard signals)
21 */
22
23 #include "toys.h"
24
25 void setsid_main(void)
26 {
27 while (setsid()<0)
28 if (vfork()) _exit(0);
29 if (toys.optflags) {
30 setpgid(0,0);
31 tcsetpgrp(0, getpid());
32 }
33 xexec(toys.optargs);
34 }