1 /* Check for proper pipe semantics at corner cases. 2 #progos: linux 3 */ 4 5 #include <stddef.h> 6 #include <stdio.h> 7 #include <stdlib.h> 8 #include <unistd.h> 9 #include <sched.h> 10 #include <signal.h> 11 #include <sys/types.h> 12 #include <sys/wait.h> 13 #include <limits.h> 14 #include <unistd.h> 15 main(void)16int main (void) 17 { 18 int i; 19 int filemax; 20 21 #ifdef OPEN_MAX 22 filemax = OPEN_MAX; 23 #else 24 filemax = sysconf (_SC_OPEN_MAX); 25 #endif 26 27 if (filemax < 10) 28 abort (); 29 30 /* Check that pipes don't leak file descriptors. */ 31 for (i = 0; i < filemax * 10; i++) 32 { 33 int pip[2]; 34 if (pipe (pip) != 0) 35 { 36 perror ("pipe"); 37 abort (); 38 } 39 40 if (close (pip[0]) != 0 || close (pip[1]) != 0) 41 { 42 perror ("close"); 43 abort (); 44 } 45 } 46 printf ("pass\n"); 47 exit (0); 48 } 49