1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-07 06:50:23 -08:00

Fix sporadic crashes and `select' failures in dumped images

* src/process.c (init_process_emacs) [HAVE_UNEXEC]: Clear
dumped values of child_signal_read_fd and child_signal_write_fd.
This commit is contained in:
Po Lu 2024-07-29 10:37:16 +08:00
parent a475360af9
commit 5cf64d8377

View file

@ -275,9 +275,9 @@ static int read_process_output (Lisp_Object, int);
static void create_pty (Lisp_Object); static void create_pty (Lisp_Object);
static void exec_sentinel (Lisp_Object, Lisp_Object); static void exec_sentinel (Lisp_Object, Lisp_Object);
static Lisp_Object static Lisp_Object network_lookup_address_info_1 (Lisp_Object, const char *,
network_lookup_address_info_1 (Lisp_Object host, const char *service, struct addrinfo *,
struct addrinfo *hints, struct addrinfo **res); struct addrinfo **);
/* Number of bits set in connect_wait_mask. */ /* Number of bits set in connect_wait_mask. */
static int num_pending_connects; static int num_pending_connects;
@ -5350,7 +5350,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
struct Lisp_Process *p; struct Lisp_Process *p;
retry_for_async = false; retry_for_async = false;
FOR_EACH_PROCESS(process_list_head, aproc) FOR_EACH_PROCESS (process_list_head, aproc)
{ {
p = XPROCESS (aproc); p = XPROCESS (aproc);
@ -5706,9 +5706,9 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
/* If wait_proc is somebody else, we have to wait in select /* If wait_proc is somebody else, we have to wait in select
as usual. Otherwise, clobber the timeout. */ as usual. Otherwise, clobber the timeout. */
if (tls_nfds > 0 if (tls_nfds > 0
&& (!wait_proc || && (!wait_proc
(wait_proc->infd >= 0 || (wait_proc->infd >= 0
&& FD_ISSET (wait_proc->infd, &tls_available)))) && FD_ISSET (wait_proc->infd, &tls_available))))
timeout = make_timespec (0, 0); timeout = make_timespec (0, 0);
#endif #endif
@ -5769,8 +5769,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
/* Slow path, merge one by one. Note: nfds does not need /* Slow path, merge one by one. Note: nfds does not need
to be accurate, just positive is enough. */ to be accurate, just positive is enough. */
for (channel = 0; channel < FD_SETSIZE; ++channel) for (channel = 0; channel < FD_SETSIZE; ++channel)
if (FD_ISSET(channel, &tls_available)) if (FD_ISSET (channel, &tls_available))
FD_SET(channel, &Available); FD_SET (channel, &Available);
} }
#endif #endif
} }
@ -8616,6 +8616,14 @@ init_process_emacs (int sockfd)
inhibit_sentinels = 0; inhibit_sentinels = 0;
#ifdef HAVE_UNEXEC
/* Clear child_signal_read_fd and child_signal_write_fd after dumping,
lest wait_reading_process_output should select on nonexistent file
descriptors which existed in the build process. */
child_signal_read_fd = -1;
child_signal_write_fd = -1;
#endif /* HAVE_UNEXEC */
if (!will_dump_with_unexec_p ()) if (!will_dump_with_unexec_p ())
{ {
#if defined HAVE_GLIB && !defined WINDOWSNT #if defined HAVE_GLIB && !defined WINDOWSNT