about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
Diffstat (limited to 'converter')
-rw-r--r--converter/other/pnmtops.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c
index 1cf23be7..a523a4f1 100644
--- a/converter/other/pnmtops.c
+++ b/converter/other/pnmtops.c
@@ -2026,6 +2026,13 @@ main(int argc, const char * argv[]) {
         name = strdup("noname");
     else
         name = basebasename(cmdline.inputFileName);
+
+    /* This program manages file descriptors in a way that assumes
+       that new files will get file descriptor numbers less than 10,
+       so we close superfluous files now to make sure that's true.
+    */
+    closeAllBut(fileno(ifP), fileno(stdout), fileno(stdout));
+
     {
         int eof;  /* There are no more images in the input file */
         unsigned int imageSeq;