* PATCH: don't call strsignal from signal handler
@ 2003-06-04 2:44 Jim Blandy
0 siblings, 0 replies; only message in thread
From: Jim Blandy @ 2003-06-04 2:44 UTC (permalink / raw)
This patch seems to fix the occasional core dumps I'd get while
checking my mail with Gnus on Red Hat GNU/Linux 8.0.
I use the following mail sources with GNUS:
(setq mail-sources
'((file)
(imap :server "localhost" :stream ssl)))
which causes Gnus to run the 'open_ssl' program to fetch my mail; I
suspect that open_ssl crashes occasionally, which led Emacs to crash
too, perhaps out of sympathy.
2003-05-30 Jim Blandy <jimb@redhat.com>
It's not safe to call strsignal in a signal handler, so have the
SIGCHLD handler just return the signal number, and get the string
when we construct Fcall_process's return value.
* callproc.c (_GNU_SOURCE): #define this, to get strsignal
declaration.
(synch_process_death): Delete variable; replaced by...
(synch_process_errno, synch_process_signo): ... new variables.
(Fcall_process): Clear both of them, instead of just
synch_process_death. In both Mac and MS-DOG cases, set either
synch_process_errno or synch_process_retcode based on value
returned by child_setup. Check all three vars and produce
Fcall_process's return value as appropriate.
* process.c (sigchld_handler): Don't look up the signal name here;
just stash it in synch_process_signo instead.
* w32proc.c (sys_wait): Set synch_process_retcode or
synch_process_signo, depending on the wait status.
* process.h (synch_process_death): Delete declaration.
(synch_process_errno, synch_process_signo): New declarations.
* sysdep.c (mkdir, rmdir): Check synch_process_errno and
synch_process_signo for error returns, instead of
synch_process_death.
*** ./src/sysdep.c.~1~ 2002-10-18 20:21:14.000000000 -0500
--- ./src/sysdep.c 2003-05-30 18:20:52.000000000 -0500
***************
*** 3767,3773 ****
wait_for_termination (cpid);
}
! if (synch_process_death != 0 || synch_process_retcode != 0)
{
errno = EIO; /* We don't know why, but */
return -1; /* /bin/mkdir failed */
--- 3767,3775 ----
wait_for_termination (cpid);
}
! if (synch_process_errno != 0
! || synch_process_signo != 0
! || synch_process_retcode != 0)
{
errno = EIO; /* We don't know why, but */
return -1; /* /bin/mkdir failed */
***************
*** 3813,3819 ****
wait_for_termination (cpid);
}
! if (synch_process_death != 0 || synch_process_retcode != 0)
{
errno = EIO; /* We don't know why, but */
return -1; /* /bin/rmdir failed */
--- 3815,3823 ----
wait_for_termination (cpid);
}
! if (synch_process_signo != 0
! || synch_process_errno != 0
! || synch_process_retcode != 0)
{
errno = EIO; /* We don't know why, but */
return -1; /* /bin/rmdir failed */
*** ./src/process.h.~1~ 1998-04-29 16:47:23.000000000 -0500
--- ./src/process.h 2003-05-30 18:25:08.000000000 -0500
***************
*** 108,121 ****
are waiting for it. */
extern int synch_process_alive;
! /* Communicate exit status of sync process to from sigchld_handler
! to Fcall_process. */
! /* Nonzero => this is a string explaining death of synchronous subprocess. */
! extern char *synch_process_death;
! /* If synch_process_death is zero,
! this is exit code of synchronous subprocess. */
extern int synch_process_retcode;
/* The name of the file open to get a null file, or a data sink.
--- 108,129 ----
are waiting for it. */
extern int synch_process_alive;
! /* Communicate exit status of sync process to from sigchld_handler to
! Fcall_process. Only one of synch_process_errno,
! synch_process_signo, and synch_process_retcode may be non-zero; if
! all of them are zero, then that's a successful exit (return code is
! zero). */
! /* If non-zero, this is the errno code from the failure to run a
! synchronous subprocess. */
! extern int synch_process_errno;
! /* If non-zero, this is the signal number the synchronous process
! received. */
! extern int synch_process_signo;
!
! /* If synch_process_errno and synch_process_signo are zero, this is
! exit code of synchronous subprocess. */
extern int synch_process_retcode;
/* The name of the file open to get a null file, or a data sink.
*** ./src/callproc.c.~1~ 2002-07-08 19:02:36.000000000 -0500
--- ./src/callproc.c 2003-05-30 18:47:19.000000000 -0500
***************
*** 20,25 ****
--- 20,26 ----
Boston, MA 02111-1307, USA. */
+ #define _GNU_SOURCE /* to get strsignal declared with glibc 2 */
#include <config.h>
#include <signal.h>
#include <errno.h>
***************
*** 121,131 ****
are waiting for it. */
int synch_process_alive;
! /* Nonzero => this is a string explaining death of synchronous subprocess. */
! char *synch_process_death;
! /* If synch_process_death is zero,
! this is exit code of synchronous subprocess. */
int synch_process_retcode;
extern Lisp_Object Vdoc_file_name;
--- 122,143 ----
are waiting for it. */
int synch_process_alive;
! /* Communicate exit status of sync process to from sigchld_handler to
! Fcall_process. Only one of synch_process_errno,
! synch_process_signo, and synch_process_retcode may be non-zero; if
! all of them are zero, then that's a successful exit (return code is
! zero). */
!
! /* If non-zero, this is the errno code from the failure to run a
! synchronous subprocess. */
! int synch_process_errno;
!
! /* If non-zero, this is the signal number the synchronous process
! received. */
! int synch_process_signo;
! /* If synch_process_errno and synch_process_signo are zero, this is
! exit code of synchronous subprocess. */
int synch_process_retcode;
extern Lisp_Object Vdoc_file_name;
***************
*** 496,502 ****
/* These vars record information from process termination.
Clear them now before process can possibly terminate,
to avoid timing error if process terminates soon. */
! synch_process_death = 0;
synch_process_retcode = 0;
if (NILP (error_file))
--- 508,515 ----
/* These vars record information from process termination.
Clear them now before process can possibly terminate,
to avoid timing error if process terminates soon. */
! synch_process_errno = 0;
! synch_process_signo = 0;
synch_process_retcode = 0;
if (NILP (error_file))
***************
*** 558,569 ****
/* Record that the synchronous process exited and note its
termination status. */
synch_process_alive = 0;
! synch_process_retcode = pid;
! if (synch_process_retcode < 0) /* means it couldn't be exec'ed */
! {
! synchronize_system_messages_locale ();
! synch_process_death = strerror (errno);
! }
/* Since CRLF is converted to LF within `decode_coding', we can
always open a file with binary mode. */
--- 571,580 ----
/* Record that the synchronous process exited and note its
termination status. */
synch_process_alive = 0;
! if (pid < 0) /* means it couldn't be exec'ed */
! synch_process_errno = errno;
! else
! synch_process_retcode = pid;
/* Since CRLF is converted to LF within `decode_coding', we can
always open a file with binary mode. */
***************
*** 586,597 ****
/* Record that the synchronous process exited and note its
termination status. */
synch_process_alive = 0;
! synch_process_retcode = pid;
! if (synch_process_retcode < 0) /* means it couldn't be exec'ed */
! {
! synchronize_system_messages_locale ();
! synch_process_death = strerror (errno);
! }
emacs_close (outfilefd);
if (fd_error != outfilefd)
--- 597,606 ----
/* Record that the synchronous process exited and note its
termination status. */
synch_process_alive = 0;
! if (pid < 0) /* means it couldn't be exec'ed */
! synch_process_errno = errno;
! else
! synch_process_retcode = pid;
emacs_close (outfilefd);
if (fd_error != outfilefd)
***************
*** 964,973 ****
unbind_to (count, Qnil);
! if (synch_process_death)
! return code_convert_string_norecord (build_string (synch_process_death),
! Vlocale_coding_system, 0);
! return make_number (synch_process_retcode);
}
#endif
\f
--- 973,996 ----
unbind_to (count, Qnil);
! if (synch_process_errno)
! {
! synchronize_system_messages_locale ();
! return code_convert_string_norecord (build_string (strerror (errno)),
! Vlocale_coding_system, 0);
! }
! else if (synch_process_signo)
! {
! char *signame;
! synchronize_system_messages_locale ();
! signame = strsignal (errno);
! if (! signame)
! signame = "unknown";
! return code_convert_string_norecord (build_string (signame),
! Vlocale_coding_system, 0);
! }
! else
! return make_number (synch_process_retcode);
}
#endif
\f
*** ./src/process.c.~1~ 2003-03-16 17:06:56.000000000 -0500
--- ./src/process.c 2003-05-30 18:19:26.000000000 -0500
***************
*** 4275,4292 ****
if (WIFEXITED (w))
synch_process_retcode = WRETCODE (w);
else if (WIFSIGNALED (w))
! {
! int code = WTERMSIG (w);
! char *signame;
!
! synchronize_system_messages_locale ();
! signame = strsignal (code);
!
! if (signame == 0)
! signame = "unknown";
!
! synch_process_death = signame;
! }
/* Tell wait_reading_process_input that it needs to wake up and
look around. */
--- 4275,4281 ----
if (WIFEXITED (w))
synch_process_retcode = WRETCODE (w);
else if (WIFSIGNALED (w))
! synch_process_signo = WTERMSIG (w);
/* Tell wait_reading_process_input that it needs to wake up and
look around. */
*** ./src/w32proc.c.~1~ 2001-06-11 06:00:03.000000000 -0500
--- ./src/w32proc.c 2003-05-30 18:22:55.000000000 -0500
***************
*** 549,566 ****
if (WIFEXITED (retval))
synch_process_retcode = WRETCODE (retval);
else if (WIFSIGNALED (retval))
! {
! int code = WTERMSIG (retval);
! char *signame;
!
! synchronize_system_messages_locale ();
! signame = strsignal (code);
!
! if (signame == 0)
! signame = "unknown";
!
! synch_process_death = signame;
! }
reap_subprocess (cp);
}
--- 549,555 ----
if (WIFEXITED (retval))
synch_process_retcode = WRETCODE (retval);
else if (WIFSIGNALED (retval))
! synch_process_signo = WTERMSIG (retval);
reap_subprocess (cp);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-06-04 2:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-04 2:44 PATCH: don't call strsignal from signal handler Jim Blandy
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).