home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / slackwar / a / util / util-lin.2 / util-lin / util-linux-2.2 / sys-utils / setsid.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-22  |  423 b   |  26 lines

  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. }
  26.