Mercurial > hg > toybox
annotate toys/setsid.c @ 528:878b94b32866
Comment and whitespace tweaks.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 06 Mar 2012 20:48:27 -0600 |
parents | 2cec41ee6eea |
children |
rev | line source |
---|---|
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 * | |
528
878b94b32866
Comment and whitespace tweaks.
Rob Landley <rob@landley.net>
parents:
371
diff
changeset
|
7 * Not in SUSv4. |
371 | 8 |
9 USE_SETSID(NEWTOY(setsid, "^<1t", TOYFLAG_USR|TOYFLAG_BIN)) | |
10 | |
11 config SETSID | |
12 bool "setsid" | |
13 default y | |
14 help | |
15 usage: setsid [-t] command [args...] | |
16 | |
17 Run process in a new session. | |
18 | |
19 -t Grab tty (become foreground process, receiving keyboard signals) | |
20 */ | |
21 | |
22 #include "toys.h" | |
23 | |
24 void setsid_main(void) | |
25 { | |
26 while (setsid()<0) | |
27 if (vfork()) _exit(0); | |
28 if (toys.optflags) { | |
29 setpgid(0,0); | |
30 tcsetpgrp(0, getpid()); | |
31 } | |
32 xexec(toys.optargs); | |
33 } |