aboutsummaryrefslogtreecommitdiff
path: root/miscutils/setsid.c
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils/setsid.c')
-rw-r--r--miscutils/setsid.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/miscutils/setsid.c b/miscutils/setsid.c
index 110bb6bb6..014de51e5 100644
--- a/miscutils/setsid.c
+++ b/miscutils/setsid.c
@@ -4,7 +4,7 @@
4 * Rick Sladkey <jrs@world.std.com> 4 * Rick Sladkey <jrs@world.std.com>
5 * In the public domain. 5 * In the public domain.
6 * 6 *
7 * 1999-02-22 Arkadiusz Mikiewicz <misiek@pld.ORG.PL> 7 * 1999-02-22 Arkadiusz Mickiewicz <misiek@pld.ORG.PL>
8 * - added Native Language Support 8 * - added Native Language Support
9 * 9 *
10 * 2001-01-18 John Fremlin <vii@penguinpowered.com> 10 * 2001-01-18 John Fremlin <vii@penguinpowered.com>
@@ -17,12 +17,14 @@
17#include "libbb.h" 17#include "libbb.h"
18 18
19int setsid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 19int setsid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
20int setsid_main(int argc, char **argv) 20int setsid_main(int argc ATTRIBUTE_UNUSED, char **argv)
21{ 21{
22 if (argc < 2) 22 if (!argv[1])
23 bb_show_usage(); 23 bb_show_usage();
24 24
25 /* Comment why is this necessary? */ 25 /* setsid() is allowed only when we are not a process group leader.
26 * Otherwise our PID serves as PGID of some existing process group
27 * and cannot be used as PGID of a new process group. */
26 if (getpgrp() == getpid()) 28 if (getpgrp() == getpid())
27 forkexit_or_rexec(argv); 29 forkexit_or_rexec(argv);
28 30