Bug fix: Fix for bug 160 broke -nw
authorNelson Ferreira <nelson.ferreira@ieee.org>
Thu, 29 Aug 2013 11:54:46 +0000 (07:54 -0400)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Thu, 29 Aug 2013 13:16:03 +0000 (09:16 -0400)
sxemacs -nw would quit right after startup

* src/lread.c (locate_file_in_directory_mapper): Only close
closure->fd if non-zero, which would be the result of the attempt
to check the file using access.

Signed-off-by: Nelson Ferreira <nelson.ferreira@ieee.org>
src/lread.c

index 30140f7..cefec89 100644 (file)
@@ -1062,7 +1062,13 @@ static int locate_file_in_directory_mapper(char *fn, void *arg)
 
                                return 1;
                        } else {
-                               close(closure->fd);
+                               /* Avoid closing stdin upon success of
+                                  access, where closure->fd would be
+                                  0 but the file is not open on that
+                                  descriptor
+                               */
+                               if(closure->fd > 0)
+                                       close(closure->fd);
                                closure->fd=-1;
                        }
                }