emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r100673: Avoid erroneous syscalls


From: Andreas Schwab
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100673: Avoid erroneous syscalls
Date: Thu, 01 Jul 2010 01:07:11 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100673
committer: Andreas Schwab <address@hidden>
branch nick: emacs
timestamp: Thu 2010-07-01 01:07:11 +0200
message:
  Avoid erroneous syscalls
  
  * process.c (create_process): Avoid using invalid file descriptors.
  
  * callproc.c (child_setup): Avoid closing a file descriptor twice.
modified:
  src/ChangeLog
  src/callproc.c
  src/process.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-06-30 23:07:00 +0000
+++ b/src/ChangeLog     2010-06-30 23:07:11 +0000
@@ -1,3 +1,9 @@
+2010-06-30  Andreas Schwab  <address@hidden>
+
+       * process.c (create_process): Avoid using invalid file descriptors.
+
+       * callproc.c (child_setup): Avoid closing a file descriptor twice.
+
 2010-06-30  Jan Djärv  <address@hidden>
 
        * xsettings.c (Ffont_get_system_normal_font, Ffont_get_system_font):

=== modified file 'src/callproc.c'
--- a/src/callproc.c    2010-06-08 03:02:41 +0000
+++ b/src/callproc.c    2010-06-30 23:07:11 +0000
@@ -1244,8 +1244,10 @@
   dup2 (out, 1);
   dup2 (err, 2);
   emacs_close (in);
-  emacs_close (out);
-  emacs_close (err);
+  if (out != in)
+    emacs_close (out);
+  if (err != in && err != out)
+    emacs_close (err);
 #endif /* not MSDOS */
 #endif /* not WINDOWSNT */
 

=== modified file 'src/process.c'
--- a/src/process.c     2010-06-09 22:08:50 +0000
+++ b/src/process.c     2010-06-30 23:07:11 +0000
@@ -2038,7 +2038,7 @@
           process_set_signal to fail on SGI when using a pipe.  */
        setsid ();
        /* Make the pty's terminal the controlling terminal.  */
-       if (pty_flag)
+       if (pty_flag && xforkin >= 0)
          {
 #ifdef TIOCSCTTY
            /* We ignore the return value
@@ -2081,8 +2081,11 @@
            /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here?
               I can't test it since I don't have 4.3.  */
            int j = emacs_open ("/dev/tty", O_RDWR, 0);
-           ioctl (j, TIOCNOTTY, 0);
-           emacs_close (j);
+           if (j >= 0)
+             {
+               ioctl (j, TIOCNOTTY, 0);
+               emacs_close (j);
+             }
 #ifndef USG
            /* In order to get a controlling terminal on some versions
               of BSD, it is necessary to put the process in pgrp 0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]