Commit 7e649856 authored by Paul Eggert's avatar Paul Eggert

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).
parent acfcc8c5
2013-07-12 Paul Eggert <eggert@cs.ucla.edu>
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).
2013-07-12 Andreas Schwab <schwab@linux-m68k.org>
* image.c (x_find_image_file): Don't close a remote file handle.
......
......@@ -7008,7 +7008,7 @@ tty_read_avail_input (struct terminal *terminal,
{
nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read);
/* POSIX infers that processes which are not in the session leader's
process group won't get SIGHUP's at logout time. BSDI adheres to
process group won't get SIGHUPs at logout time. BSDI adheres to
this part standard and returns -1 from read (0) with errno==EIO
when the control tty is taken away.
Jeffrey Honig <jch@bsdi.com> says this is generally safe. */
......
......@@ -1812,12 +1812,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
SETUP_SLAVE_PTY;
}
#endif /* SETUP_SLAVE_PTY */
#ifdef AIX
/* On AIX, we've disabled SIGHUP above once we start a child on a pty.
Now reenable it in the child, so it will die when we want it to. */
if (pty_flag)
signal (SIGHUP, SIG_DFL);
#endif
#endif /* HAVE_PTYS */
signal (SIGINT, SIG_DFL);
......@@ -4632,20 +4626,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
if (xerrno == EINTR)
no_avail = 1;
else if (xerrno == EBADF)
{
#ifdef AIX
/* AIX doesn't handle PTY closure the same way BSD does. On AIX,
the child's closure of the pts gives the parent a SIGHUP, and
the ptc file descriptor is automatically closed,
yielding EBADF here or at select() call above.
So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
in m/ibmrt-aix.h), and here we just ignore the select error.
Cleanup occurs c/o status_notify after SIGCHLD. */
no_avail = 1; /* Cannot depend on values returned */
#else
emacs_abort ();
#endif
}
emacs_abort ();
else
error ("select error: %s", emacs_strerror (xerrno));
}
......
......@@ -2237,8 +2237,8 @@ posix_close (int fd, int flag)
arriving. FD is always closed when this function returns, even
when it returns -1.
Do not call this function if FD might already be closed, as that
might close an innocent victim opened by some other thread. */
Do not call this function if FD is nonnegative and might already be closed,
as that might close an innocent victim opened by some other thread. */
int
emacs_close (int fd)
......@@ -2250,7 +2250,7 @@ emacs_close (int fd)
return r;
if (!POSIX_CLOSE_RESTART || errno != EINTR)
{
eassert (errno != EBADF);
eassert (errno != EBADF || fd < 0);
return errno == EINPROGRESS ? 0 : r;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment