From: Po Lu Date: Mon, 29 Jul 2024 02:37:16 +0000 (+0800) Subject: Fix sporadic crashes and `select' failures in dumped images X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b330cf5b05428c1b2dfa0bfb66f4c95375b9a0d3;p=emacs.git 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. (cherry picked from commit 5cf64d8377ad43f9a7b0ad28cbb4a494b403806b) --- diff --git a/src/process.c b/src/process.c index 93178eb241f..73600157835 100644 --- a/src/process.c +++ b/src/process.c @@ -275,9 +275,9 @@ static int read_process_output (Lisp_Object, int); static void create_pty (Lisp_Object); static void exec_sentinel (Lisp_Object, Lisp_Object); -static Lisp_Object -network_lookup_address_info_1 (Lisp_Object host, const char *service, - struct addrinfo *hints, struct addrinfo **res); +static Lisp_Object network_lookup_address_info_1 (Lisp_Object, const char *, + struct addrinfo *, + struct addrinfo **); /* Number of bits set in connect_wait_mask. */ 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; retry_for_async = false; - FOR_EACH_PROCESS(process_list_head, aproc) + FOR_EACH_PROCESS (process_list_head, 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 as usual. Otherwise, clobber the timeout. */ if (tls_nfds > 0 - && (!wait_proc || - (wait_proc->infd >= 0 - && FD_ISSET (wait_proc->infd, &tls_available)))) + && (!wait_proc + || (wait_proc->infd >= 0 + && FD_ISSET (wait_proc->infd, &tls_available)))) timeout = make_timespec (0, 0); #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 to be accurate, just positive is enough. */ for (channel = 0; channel < FD_SETSIZE; ++channel) - if (FD_ISSET(channel, &tls_available)) - FD_SET(channel, &Available); + if (FD_ISSET (channel, &tls_available)) + FD_SET (channel, &Available); } #endif } @@ -8616,6 +8616,14 @@ init_process_emacs (int sockfd) 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 defined HAVE_GLIB && !defined WINDOWSNT