• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/gdb/sim/testsuite/sim/cris/c/
1/* Check that TRT happens when error on pipe call.
2#notarget: cris*-*-elf
3*/
4
5#include <stddef.h>
6#include <stdio.h>
7#include <stdlib.h>
8#include <unistd.h>
9#include <errno.h>
10#include <limits.h>
11
12int main (void)
13{
14  int i;
15  int filemax;
16
17#ifdef OPEN_MAX
18  filemax = OPEN_MAX;
19#else
20  filemax = sysconf (_SC_OPEN_MAX);
21#endif
22
23  /* Check that TRT happens when error on pipe call.  */
24  for (i = 0; i < filemax + 1; i++)
25    {
26      int pip[2];
27      if (pipe (pip) != 0)
28	{
29	  /* Shouldn't happen too early.  */
30	  if (i < filemax / 2 - 3 - 1)
31	    {
32	      fprintf (stderr, "i: %d\n", i);
33	      abort ();
34	    }
35	  if (errno != EMFILE)
36	    {
37	      perror ("pipe");
38	      abort ();
39	    }
40	  goto ok;
41	}
42    }
43  abort ();
44
45ok:
46  printf ("pass\n");
47  exit (0);
48}
49