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