Create new pgrp so that we can use killpg
This commit is contained in:
1 parent
872be9a796
commit
240278bb22
1 file changed
+11
-10
@@ -183,19 +183,20 @@ int main(int argc, char *argv[])
|
||||
for (fd = getdtablesize(); fd > 2; fd--) close(fd);
|
||||
}
|
||||
|
||||
/* Use a new process group so we can use killpg */
|
||||
setpgid( 0, 0 );
|
||||
|
||||
/* XXX We should not fork twice if we don't need to!! */
|
||||
if (detachtty) {
|
||||
/* detach from tty */
|
||||
if (getpgrp() == getpid()) {
|
||||
switch(fork()) {
|
||||
case -1:
|
||||
perror("fork");
|
||||
return 1;
|
||||
case 0: /* child */
|
||||
break;
|
||||
default: /* parent */
|
||||
return 0;
|
||||
}
|
||||
switch(fork()) {
|
||||
case -1:
|
||||
perror("fork");
|
||||
return 1;
|
||||
case 0: /* child */
|
||||
break;
|
||||
default: /* parent */
|
||||
return 0;
|
||||
}
|
||||
setsid();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user