summaryrefslogtreecommitdiff
path: root/manual/examples
diff options
context:
space:
mode:
Diffstat (limited to 'manual/examples')
-rw-r--r--manual/examples/popen.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/manual/examples/popen.c b/manual/examples/popen.c
index 16ae32fa16..1b9ee826b4 100644
--- a/manual/examples/popen.c
+++ b/manual/examples/popen.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
-void
+void
write_data (FILE * stream)
{
int i;
@@ -23,11 +23,16 @@ main (void)
output = popen ("more", "w");
if (!output)
{
- fprintf (stderr, "Could not run more.\n");
+ fprintf (stderr,
+ "incorrect parameters or too many files.\n");
return EXIT_FAILURE;
}
write_data (output);
- pclose (output);
+ if (pclose (output) != 0)
+ {
+ fprintf (stderr,
+ "Could not run more or other error.\n");
+ }
return EXIT_SUCCESS;
}
/*@end group*/