]>
Commit | Line | Data |
---|---|---|
6dbe3af9 KZ |
1 | /* |
2 | * setsid.c -- execute a command in a new session | |
3 | * Rick Sladkey <jrs@world.std.com> | |
4 | * In the public domain. | |
5 | */ | |
6 | ||
7 | #include <stdio.h> | |
8 | #include <unistd.h> | |
9 | #include <stdlib.h> | |
10 | ||
11 | int main(int argc, char *argv[]) | |
12 | { | |
13 | if (argc < 2) { | |
14 | fprintf(stderr, "usage: %s program [arg ...]\n", | |
15 | argv[0]); | |
16 | exit(1); | |
17 | } | |
18 | if (setsid() < 0) { | |
19 | perror("setsid"); | |
20 | exit(1); | |
21 | } | |
22 | execvp(argv[1], argv + 1); | |
23 | perror("execvp"); | |
24 | exit(1); | |
25 | } |