aboutsummaryrefslogtreecommitdiffstats
path: root/sys-utils/setsid.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys-utils/setsid.c')
-rw-r--r--sys-utils/setsid.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/sys-utils/setsid.c b/sys-utils/setsid.c
new file mode 100644
index 0000000000..10f1501d68
--- /dev/null
+++ b/sys-utils/setsid.c
@@ -0,0 +1,25 @@
+/*
+ * setsid.c -- execute a command in a new session
+ * Rick Sladkey <jrs@world.std.com>
+ * In the public domain.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s program [arg ...]\n",
+ argv[0]);
+ exit(1);
+ }
+ if (setsid() < 0) {
+ perror("setsid");
+ exit(1);
+ }
+ execvp(argv[1], argv + 1);
+ perror("execvp");
+ exit(1);
+}