about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-11-12 02:55:27 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-11-12 02:55:27 +0000
commitbd53380a057c8ad9e8118bfd0e2675a4907fc737 (patch)
tree8cb9d037e7ffe8dd422bbf37a520bc726b2fbd92
parenta048d4a92949f843efefb3a6c60c746b76cbddbb (diff)
downloadnetpbm-mirror-bd53380a057c8ad9e8118bfd0e2675a4907fc737.tar.gz
netpbm-mirror-bd53380a057c8ad9e8118bfd0e2675a4907fc737.tar.xz
netpbm-mirror-bd53380a057c8ad9e8118bfd0e2675a4907fc737.zip
Close inherited files to keep new file descriptor numbers < 10
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2031 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/pnmtops.c7
-rw-r--r--doc/HISTORY2
2 files changed, 9 insertions, 0 deletions
diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c
index 6c83f38e..5e7d1563 100644
--- a/converter/other/pnmtops.c
+++ b/converter/other/pnmtops.c
@@ -2036,6 +2036,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;
diff --git a/doc/HISTORY b/doc/HISTORY
index 6b298ec9..08c705b0 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -9,6 +9,8 @@ not yet  BJH  Release 10.65.00
               Recognize SIGPWR on systems that have it in messages
               about signal received.
 
+              Fix bug: program hangs if it inherits lots of open files.
+
               Build for big-endian machines: fix syntax error so it compiles.
               Broken in 10.63 (June 2013).