6 DEFUN(write_data
, (stream
), FILE *stream
)
10 fprintf (stream
, "%d\n", i
);
11 if (ferror (stream
)) {
12 fprintf (stderr
, "Output to stream failed.\n");
18 DEFUN(read_data
, (stream
), FILE *stream
)
24 if (fscanf (stream
, "%d\n", &j
) != 1 || j
!= i
)
28 puts ("Test FAILED!");
40 output
= popen ("/bin/cat >/tmp/tstpopen.tmp", "w");
44 puts ("Test FAILED!");
48 wstatus
= pclose (output
);
49 printf ("writing pclose returned %d\n", wstatus
);
50 input
= popen ("/bin/cat /tmp/tstpopen.tmp", "r");
53 perror ("/tmp/tstpopen.tmp");
54 puts ("Test FAILED!");
58 rstatus
= pclose (input
);
59 printf ("reading pclose returned %d\n", rstatus
);
61 remove ("/tmp/tstpopen.tmp");
63 puts (wstatus
| rstatus
? "Test FAILED!" : "Test succeeded.");
64 exit (wstatus
| rstatus
);