"Fossies" - the Fresh Open Source Software Archive

Member "delegate9.9.13/maker/setsid.c" (16 Aug 2009, 409 Bytes) of package /linux/misc/old/delegate9.9.13.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "setsid.c" see the Fossies "Dox" file reference documentation.

    1 int SUBST_setsid = 1;
    2 #include <sys/ioctl.h>
    3 
    4 #if defined(hpux) || defined(__hpux__)
    5 #include <sys/file.h>
    6 #define TIOCNOTTY       O_NOCTTY
    7 #endif
    8 
    9 int open(char*,int);
   10 int close(int);
   11 int getpid();
   12 
   13 int setsid()
   14 {       int fd;
   15 
   16 #ifdef TIOCNOTTY
   17         if( 0 <= (fd = open("/dev/tty",0)) ){
   18                 ioctl(fd,TIOCNOTTY,0);
   19                 close(fd);
   20         return getpid();
   21         }
   22 #endif
   23     return -1;
   24 }