summaryrefslogtreecommitdiffstats
path: root/sys-utils/setsid.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:32 +0100
committerKarel Zak2006-12-07 00:25:32 +0100
commit6dbe3af945a63f025561abb83275cee9ff06c57b (patch)
tree19e59eac8ac465b5bc409b5adf815b582c92f633 /sys-utils/setsid.c
downloadkernel-qcow2-util-linux-6dbe3af945a63f025561abb83275cee9ff06c57b.tar.gz
kernel-qcow2-util-linux-6dbe3af945a63f025561abb83275cee9ff06c57b.tar.xz
kernel-qcow2-util-linux-6dbe3af945a63f025561abb83275cee9ff06c57b.zip
Imported from util-linux-2.2 tarball.
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 000000000..10f1501d6
--- /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);
+}