(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.c-torture/
compile/
991026-2.c
       1  typedef int __pid_t;			 
       2  extern __pid_t fork  (void)    ;
       3  extern int printf  (__const char *__restrict __format, ...)    ;
       4  extern char *strerror  (int __errnum)    ;
       5  extern int errno;
       6  extern int *__errno_location  (void)     __attribute__ ((__const__));
       7  extern void _exit  (int __status)   __attribute__ ((__noreturn__));
       8  extern void exit  (int __status)     __attribute__ ((__noreturn__));
       9  extern int close  (int __fd)    ;
      10  extern int dup  (int __fd)    ;
      11  extern int open  (__const char *__file, int __oflag, ...)    ;
      12  
      13  
      14  char	myname[]="foo";
      15  
      16  detach()
      17  {
      18  	switch(fork()) {
      19  	    case -1:
      20  		printf("%s: Error: fork - %s\n",myname, strerror((*__errno_location ()) ));
      21  		exit(255);
      22  	    case 0:
      23  		 
      24  		close(0);
      25  		close(1);
      26  		close(2);
      27  		dup(dup(open("/dev/null", 02 )));
      28  		return;
      29  	    default:
      30  		 
      31  		_exit(0);
      32  	}
      33  }