This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21
22 #include "stdio--.h"
23
24
25 #include <sys/wait.h>
26 #include <unistd.h>
27
28
29
30
31
32 #define BACKUP_STDERR_FILENO 10
33 #define ASSERT_STREAM myerr
34 #include "macros.h"
35
36 static FILE *myerr;
37
38 int
39 main (int argc, char **argv)
40 {
41 FILE *fp;
42 int status;
43
44
45 if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO
46 || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL)
47 return 2;
48
49 ASSERT (fp = popen ("exit 0", "r"));
50 ASSERT (STDERR_FILENO < fileno (fp));
51 status = pclose (fp);
52 ASSERT (WIFEXITED (status));
53 ASSERT (!WEXITSTATUS (status));
54
55 ASSERT (fclose (stdin) == 0);
56 ASSERT (fp = popen ("exit 0", "r"));
57 ASSERT (STDERR_FILENO < fileno (fp));
58 status = pclose (fp);
59 ASSERT (WIFEXITED (status));
60 ASSERT (!WEXITSTATUS (status));
61
62 ASSERT (fclose (stdout) == 0);
63 ASSERT (fp = popen ("exit 0", "r"));
64 ASSERT (STDERR_FILENO < fileno (fp));
65 status = pclose (fp);
66 ASSERT (WIFEXITED (status));
67 ASSERT (!WEXITSTATUS (status));
68
69 ASSERT (fclose (stderr) == 0);
70 ASSERT (fp = popen ("exit 0", "r"));
71 ASSERT (STDERR_FILENO < fileno (fp));
72 status = pclose (fp);
73 ASSERT (WIFEXITED (status));
74 ASSERT (!WEXITSTATUS (status));
75 return 0;
76 }