1 /* Check for proper pipe semantics at corner cases.
2 #notarget: cris*-*-elf
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 
main(void)15 int main (void)
16 {
17   int i;
18   int filemax;
19 
20 #ifdef OPEN_MAX
21   filemax = OPEN_MAX;
22 #else
23   filemax = sysconf (_SC_OPEN_MAX);
24 #endif
25 
26   if (filemax < 10)
27     abort ();
28 
29   /* Check that pipes don't leak file descriptors.  */
30   for (i = 0; i < filemax * 10; i++)
31     {
32       int pip[2];
33       if (pipe (pip) != 0)
34 	{
35 	  perror ("pipe");
36 	  abort ();
37 	}
38 
39       if (close (pip[0]) != 0 || close (pip[1]) != 0)
40 	{
41 	  perror ("close");
42 	  abort ();
43 	}
44     }
45   printf ("pass\n");
46   exit (0);
47 }
48