* sysdeps/m68k/setjmp.c: Also define setjmp and _setjmp if
[glibc.git] / manual / examples / popen.c
blob1b9ee826b49cd901ddfee4db402fbe644b0cdbda
1 #include <stdio.h>
2 #include <stdlib.h>
4 void
5 write_data (FILE * stream)
7 int i;
8 for (i = 0; i < 100; i++)
9 fprintf (stream, "%d\n", i);
10 if (ferror (stream))
12 fprintf (stderr, "Output to stream failed.\n");
13 exit (EXIT_FAILURE);
17 /*@group*/
18 int
19 main (void)
21 FILE *output;
23 output = popen ("more", "w");
24 if (!output)
26 fprintf (stderr,
27 "incorrect parameters or too many files.\n");
28 return EXIT_FAILURE;
30 write_data (output);
31 if (pclose (output) != 0)
33 fprintf (stderr,
34 "Could not run more or other error.\n");
36 return EXIT_SUCCESS;
38 /*@end group*/