aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-07-12 07:31:42 -0700
committerPaul Eggert2013-07-12 07:31:42 -0700
commit7e649856bce883738622cc3533ad808c6ea1a73f (patch)
tree7f5d1f3fffd1b0097ba8fa4e8cbbb2a0d100b6bc /src
parentacfcc8c53bcfca52f4ab4ff527d39533545566d9 (diff)
downloademacs-7e649856bce883738622cc3533ad808c6ea1a73f.tar.gz
emacs-7e649856bce883738622cc3533ad808c6ea1a73f.zip
Minor EBADF fixes.
* process.c (create_process, wait_reading_process_output) [AIX]: Remove obsolete SIGHUP-related code, as Emacs no longer disables SIGHUP, so EBADF is no longer acceptable here (it wouldn't work in a multithreaded environment anyway). * sysdep.c (emacs_close): It's not dangerous to invoke emacs_close (-1).
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/keyboard.c2
-rw-r--r--src/process.c21
-rw-r--r--src/sysdep.c6
4 files changed, 14 insertions, 24 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 75031274694..dfc74d7bb39 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12013-07-12 Paul Eggert <eggert@cs.ucla.edu>
2
3 Minor EBADF fixes.
4 * process.c (create_process, wait_reading_process_output) [AIX]:
5 Remove obsolete SIGHUP-related code, as Emacs no longer disables
6 SIGHUP, so EBADF is no longer acceptable here (it wouldn't work in
7 a multithreaded environment anyway).
8 * sysdep.c (emacs_close): It's not dangerous to invoke emacs_close (-1).
9
12013-07-12 Andreas Schwab <schwab@linux-m68k.org> 102013-07-12 Andreas Schwab <schwab@linux-m68k.org>
2 11
3 * image.c (x_find_image_file): Don't close a remote file handle. 12 * image.c (x_find_image_file): Don't close a remote file handle.
diff --git a/src/keyboard.c b/src/keyboard.c
index 39535f5cd71..b6eb9e6ad15 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7008,7 +7008,7 @@ tty_read_avail_input (struct terminal *terminal,
7008 { 7008 {
7009 nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read); 7009 nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read);
7010 /* POSIX infers that processes which are not in the session leader's 7010 /* POSIX infers that processes which are not in the session leader's
7011 process group won't get SIGHUP's at logout time. BSDI adheres to 7011 process group won't get SIGHUPs at logout time. BSDI adheres to
7012 this part standard and returns -1 from read (0) with errno==EIO 7012 this part standard and returns -1 from read (0) with errno==EIO
7013 when the control tty is taken away. 7013 when the control tty is taken away.
7014 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ 7014 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */
diff --git a/src/process.c b/src/process.c
index bdab1f8cb8a..81be29082fc 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1812,12 +1812,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1812 SETUP_SLAVE_PTY; 1812 SETUP_SLAVE_PTY;
1813 } 1813 }
1814#endif /* SETUP_SLAVE_PTY */ 1814#endif /* SETUP_SLAVE_PTY */
1815#ifdef AIX
1816 /* On AIX, we've disabled SIGHUP above once we start a child on a pty.
1817 Now reenable it in the child, so it will die when we want it to. */
1818 if (pty_flag)
1819 signal (SIGHUP, SIG_DFL);
1820#endif
1821#endif /* HAVE_PTYS */ 1815#endif /* HAVE_PTYS */
1822 1816
1823 signal (SIGINT, SIG_DFL); 1817 signal (SIGINT, SIG_DFL);
@@ -4632,20 +4626,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4632 if (xerrno == EINTR) 4626 if (xerrno == EINTR)
4633 no_avail = 1; 4627 no_avail = 1;
4634 else if (xerrno == EBADF) 4628 else if (xerrno == EBADF)
4635 { 4629 emacs_abort ();
4636#ifdef AIX
4637 /* AIX doesn't handle PTY closure the same way BSD does. On AIX,
4638 the child's closure of the pts gives the parent a SIGHUP, and
4639 the ptc file descriptor is automatically closed,
4640 yielding EBADF here or at select() call above.
4641 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
4642 in m/ibmrt-aix.h), and here we just ignore the select error.
4643 Cleanup occurs c/o status_notify after SIGCHLD. */
4644 no_avail = 1; /* Cannot depend on values returned */
4645#else
4646 emacs_abort ();
4647#endif
4648 }
4649 else 4630 else
4650 error ("select error: %s", emacs_strerror (xerrno)); 4631 error ("select error: %s", emacs_strerror (xerrno));
4651 } 4632 }
diff --git a/src/sysdep.c b/src/sysdep.c
index a1f217b39a6..f614d8bc557 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -2237,8 +2237,8 @@ posix_close (int fd, int flag)
2237 arriving. FD is always closed when this function returns, even 2237 arriving. FD is always closed when this function returns, even
2238 when it returns -1. 2238 when it returns -1.
2239 2239
2240 Do not call this function if FD might already be closed, as that 2240 Do not call this function if FD is nonnegative and might already be closed,
2241 might close an innocent victim opened by some other thread. */ 2241 as that might close an innocent victim opened by some other thread. */
2242 2242
2243int 2243int
2244emacs_close (int fd) 2244emacs_close (int fd)
@@ -2250,7 +2250,7 @@ emacs_close (int fd)
2250 return r; 2250 return r;
2251 if (!POSIX_CLOSE_RESTART || errno != EINTR) 2251 if (!POSIX_CLOSE_RESTART || errno != EINTR)
2252 { 2252 {
2253 eassert (errno != EBADF); 2253 eassert (errno != EBADF || fd < 0);
2254 return errno == EINPROGRESS ? 0 : r; 2254 return errno == EINPROGRESS ? 0 : r;
2255 } 2255 }
2256 } 2256 }