From 6e432f0cda1daa7bcee1fb5872dcfa130abe5018 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 13 Feb 2013 19:00:26 +0200 Subject: Cleanup related to bug #13546 with subprocesses on MS-Windows. src/w32.c (sys_pipe): When failing due to file descriptors above MAXDESC, set errno to EMFILE. (_sys_read_ahead): Update cp->status when failing to read serial communications input, so that the status doesn't stay at STATUS_READ_IN_PROGRESS. --- src/ChangeLog | 8 ++++++++ src/w32.c | 21 +++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 62d33e15ece..358f25b40f9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2013-02-13 Eli Zaretskii + + * w32.c (sys_pipe): When failing due to file descriptors above + MAXDESC, set errno to EMFILE. + (_sys_read_ahead): Update cp->status when failing to read serial + communications input, so that the status doesn't stay at + STATUS_READ_IN_PROGRESS. (Bug#13546) + 2013-02-13 Glenn Morris * keyboard.c (input-decode-map, key-translation-map): Doc fixes. diff --git a/src/w32.c b/src/w32.c index 802403168f0..214fb7fdfae 100644 --- a/src/w32.c +++ b/src/w32.c @@ -6209,6 +6209,7 @@ sys_pipe (int * phandles) { _close (phandles[0]); _close (phandles[1]); + errno = EMFILE; rc = -1; } else @@ -6281,19 +6282,31 @@ _sys_read_ahead (int fd) /* Configure timeouts for blocking read. */ if (!GetCommTimeouts (hnd, &ct)) - return STATUS_READ_ERROR; + { + cp->status = STATUS_READ_ERROR; + return STATUS_READ_ERROR; + } ct.ReadIntervalTimeout = 0; ct.ReadTotalTimeoutMultiplier = 0; ct.ReadTotalTimeoutConstant = 0; if (!SetCommTimeouts (hnd, &ct)) - return STATUS_READ_ERROR; + { + cp->status = STATUS_READ_ERROR; + return STATUS_READ_ERROR; + } if (!ReadFile (hnd, &cp->chr, sizeof (char), (DWORD*) &rc, ovl)) { if (GetLastError () != ERROR_IO_PENDING) - return STATUS_READ_ERROR; + { + cp->status = STATUS_READ_ERROR; + return STATUS_READ_ERROR; + } if (!GetOverlappedResult (hnd, ovl, (DWORD*) &rc, TRUE)) - return STATUS_READ_ERROR; + { + cp->status = STATUS_READ_ERROR; + return STATUS_READ_ERROR; + } } } else if (fd_info[fd].flags & FILE_SOCKET) -- cgit v1.2.1 From 0e4e7b741b515be091e2ec3b3ff63f1b16084555 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 13 Feb 2013 19:04:30 +0200 Subject: More robust creation of a subprocess, attempt to solve bug #13546. src/w32proc.c (new_child): If no vacant slots are found in child_procs[], make another pass looking for slots whose process has exited or died. --- src/ChangeLog | 4 ++++ src/w32proc.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 358f25b40f9..e1b8a23e6b2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2013-02-13 Eli Zaretskii + * w32proc.c (new_child): If no vacant slots are found in + child_procs[], make another pass looking for slots whose process + has exited or died. (Bug#13546) + * w32.c (sys_pipe): When failing due to file descriptors above MAXDESC, set errno to EMFILE. (_sys_read_ahead): Update cp->status when failing to read serial diff --git a/src/w32proc.c b/src/w32proc.c index 8c09a1b1beb..1e72d41e16b 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -797,6 +797,33 @@ new_child (void) for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL) goto Initialize; + if (child_proc_count == MAX_CHILDREN) + { + DebPrint (("new_child: No vacant slots, looking for dead processes\n")); + for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) + if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess) + { + DWORD status = 0; + + if (!GetExitCodeProcess (cp->procinfo.hProcess, &status)) + { + DebPrint (("new_child.GetExitCodeProcess: error %lu for PID %lu\n", + GetLastError (), cp->procinfo.dwProcessId)); + status = STILL_ACTIVE; + } + if (status != STILL_ACTIVE + || WaitForSingleObject (cp->procinfo.hProcess, 0) == WAIT_OBJECT_0) + { + DebPrint (("new_child: Freeing slot of dead process %d\n", + cp->procinfo.dwProcessId)); + CloseHandle (cp->procinfo.hProcess); + cp->procinfo.hProcess = NULL; + CloseHandle (cp->procinfo.hThread); + cp->procinfo.hThread = NULL; + goto Initialize; + } + } + } if (child_proc_count == MAX_CHILDREN) return NULL; cp = &child_procs[child_proc_count++]; -- cgit v1.2.1 From 35b3a27e67b60e547ac8bc9388e7724d1f829959 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 14 Feb 2013 12:05:10 -0800 Subject: Fix AIX port. * configure.ac (DATA_START, DATA_SEG_BITS): Set to 0x20000000 on AIX. (GC_MARK_STACK): Do not set to GC_USE_GCPROS_AS_BEFORE, as that runs afoul of some other bug in Emacs, and the default value GC_MAKE_GCPROS_NOOPS has been tested and works. * src/lisp.h (XPNTR) [!USE_LSB_TAG && DATA_SEG_BITS]: Fix bug introduced in 2012-07-27 change. DATA_SEG_BITS, if set, was #undeffed earlier, so it cannot be used as a macro here. Use the constant and not the macro. Tested on AIX. * src/unexaix.c: Revert 2013-02-11 and 2013-02-12 changes to this file. They're almost surely OK but we're just before a release so we should avoid changes unless they're clearly needed. Instead, make the following minor change: (ADDR_CORRECT): New macro. Fixes: debbugs:13650 --- src/ChangeLog | 13 ++++++++ src/lisp.h | 4 --- src/unexaix.c | 96 +++++++++++++++++++++++++++++++---------------------------- 3 files changed, 64 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index e1b8a23e6b2..e283d2bb48c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2013-02-14 Paul Eggert + + Fix AIX port (Bug#13650). + * lisp.h (XPNTR) [!USE_LSB_TAG && DATA_SEG_BITS]: + Fix bug introduced in 2012-07-27 change. DATA_SEG_BITS, if set, + was #undeffed earlier, so it cannot be used as a macro here. + Use the constant and not the macro. + * unexaix.c: Revert 2013-02-11 and 2013-02-12 changes to this + file. They're almost surely OK but we're just before a release so + we should avoid changes unless they're clearly needed. Instead, + make the following minor change: + (ADDR_CORRECT): New macro. + 2013-02-13 Eli Zaretskii * w32proc.c (new_child): If no vacant slots are found in diff --git a/src/lisp.h b/src/lisp.h index a62842c117a..eca3caefd8c 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -496,13 +496,9 @@ static EMACS_INT const VALMASK (XIL ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ + ((intptr_t) (ptr) & VALMASK))) -#if DATA_SEG_BITS /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers which were stored in a Lisp_Object. */ #define XPNTR(a) ((uintptr_t) ((XLI (a) & VALMASK)) | DATA_SEG_BITS)) -#else -#define XPNTR(a) ((uintptr_t) (XLI (a) & VALMASK)) -#endif #endif /* not USE_LSB_TAG */ diff --git a/src/unexaix.c b/src/unexaix.c index da44480fdca..885d7a9f6d7 100644 --- a/src/unexaix.c +++ b/src/unexaix.c @@ -51,8 +51,6 @@ what you give them. Help stamp out software-hoarding! */ #include "getpagesize.h" #include -#include -#include #include #include #include @@ -61,8 +59,10 @@ what you give them. Help stamp out software-hoarding! */ #include "mem-limits.h" -extern char _data[]; -extern char _text[]; +char *start_of_text (void); /* Start of text */ + +extern int _data; +extern int _text; #include #include @@ -71,15 +71,15 @@ extern char _text[]; static struct filehdr f_hdr; /* File header */ static struct aouthdr f_ohdr; /* Optional file header (a.out) */ -static off_t bias; /* Bias to add for growth */ -static off_t lnnoptr; /* Pointer to line-number info within file */ +static long bias; /* Bias to add for growth */ +static long lnnoptr; /* Pointer to line-number info within file */ -static off_t text_scnptr; -static off_t data_scnptr; +static long text_scnptr; +static long data_scnptr; #define ALIGN(val, pwr) (((val) + ((1L<<(pwr))-1)) & ~((1L<<(pwr))-1)) -static off_t load_scnptr; -static off_t orig_load_scnptr; -static off_t orig_data_scnptr; +static long load_scnptr; +static long orig_load_scnptr; +static long orig_data_scnptr; static int unrelocate_symbols (int, int, const char *, const char *); #ifndef MAX_SECTIONS @@ -92,30 +92,26 @@ static int pagemask; #include "lisp.h" -static _Noreturn void +static void report_error (const char *file, int fd) { if (fd) - { - int failed_errno = errno; - close (fd); - errno = failed_errno; - } + close (fd); report_file_error ("Cannot unexec", Fcons (build_string (file), Qnil)); } -#define ERROR0(msg) report_error_1 (new, msg) -#define ERROR1(msg,x) report_error_1 (new, msg, x) -#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y) +#define ERROR0(msg) report_error_1 (new, msg, 0, 0); return -1 +#define ERROR1(msg,x) report_error_1 (new, msg, x, 0); return -1 +#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 -static _Noreturn void ATTRIBUTE_FORMAT_PRINTF (2, 3) -report_error_1 (int fd, const char *msg, ...) +#undef ADDR_CORRECT +#define ADDR_CORRECT(x) ((int)(x)) + +static void +report_error_1 (int fd, const char *msg, int a1, int a2) { - va_list ap; close (fd); - va_start (ap, msg); - verror (msg, ap); - va_end (ap); + error (msg, a1, a2); } static int make_hdr (int, int, const char *, const char *); @@ -170,8 +166,8 @@ make_hdr (int new, int a_out, const char *a_name, const char *new_name) { int scns; - uintptr_t bss_start; - uintptr_t data_start; + unsigned int bss_start; + unsigned int data_start; struct scnhdr section[MAX_SECTIONS]; struct scnhdr * f_thdr; /* Text section header */ @@ -186,17 +182,17 @@ make_hdr (int new, int a_out, pagemask = getpagesize () - 1; /* Adjust text/data boundary. */ - data_start = (uintptr_t) _data; + data_start = (long) start_of_data (); + data_start = ADDR_CORRECT (data_start); data_start = data_start & ~pagemask; /* (Down) to page boundary. */ - bss_start = (uintptr_t) sbrk (0) + pagemask; + bss_start = ADDR_CORRECT (sbrk (0)) + pagemask; bss_start &= ~ pagemask; if (data_start > bss_start) /* Can't have negative data size. */ { - ERROR2 (("unexec: data_start (0x%"PRIxPTR - ") can't be greater than bss_start (0x%"PRIxPTR")"), + ERROR2 ("unexec: data_start (%u) can't be greater than bss_start (%u)", data_start, bss_start); } @@ -286,7 +282,7 @@ make_hdr (int new, int a_out, /* fix scnptr's */ { - off_t ptr = section[0].s_scnptr; + ulong ptr = section[0].s_scnptr; bias = -1; for (scns = 0; scns < f_hdr.f_nscns; scns++) @@ -382,12 +378,12 @@ copy_text_and_data (int new) char *end; char *ptr; - lseek (new, text_scnptr, SEEK_SET); - ptr = _text + text_scnptr; + lseek (new, (long) text_scnptr, SEEK_SET); + ptr = start_of_text () + text_scnptr; end = ptr + f_ohdr.tsize; write_segment (new, ptr, end); - lseek (new, data_scnptr, SEEK_SET); + lseek (new, (long) data_scnptr, SEEK_SET); ptr = (char *) f_ohdr.data_start; end = ptr + f_ohdr.dsize; write_segment (new, ptr, end); @@ -400,6 +396,7 @@ static void write_segment (int new, char *ptr, char *end) { int i, nwrite, ret; + char buf[80]; char zeros[UnexBlockSz]; for (i = 0; ptr < end;) @@ -420,13 +417,9 @@ write_segment (int new, char *ptr, char *end) } else if (nwrite != ret) { - int write_errno = errno; - char buf[1000]; - void *addr = ptr; sprintf (buf, - "unexec write failure: addr %p, fileno %d, size 0x%x, wrote 0x%x, errno %d", - addr, new, nwrite, ret, errno); - errno = write_errno; + "unexec write failure: addr 0x%lx, fileno %d, size 0x%x, wrote 0x%x, errno %d", + (unsigned long)ptr, new, nwrite, ret, errno); PERROR (buf); } i += nwrite; @@ -547,13 +540,13 @@ unrelocate_symbols (int new, int a_out, int i; LDHDR ldhdr; LDREL ldrel; - off_t t_reloc = (intptr_t) _text - f_ohdr.text_start; + ulong t_reloc = (ulong) &_text - f_ohdr.text_start; #ifndef ALIGN_DATA_RELOC - off_t d_reloc = (intptr_t) _data - f_ohdr.data_start; + ulong d_reloc = (ulong) &_data - f_ohdr.data_start; #else /* This worked (and was needed) before AIX 4.2. I have no idea why. -- Mike */ - off_t d_reloc = (intptr_t) _data - ALIGN (f_ohdr.data_start, 2); + ulong d_reloc = (ulong) &_data - ALIGN (f_ohdr.data_start, 2); #endif int * p; @@ -638,3 +631,16 @@ unrelocate_symbols (int new, int a_out, } return 0; } + +/* + * Return the address of the start of the text segment prior to + * doing an unexec. After unexec the return value is undefined. + * See crt0.c for further explanation and _start. + * + */ + +char * +start_of_text (void) +{ + return ((char *) 0x10000000); +} -- cgit v1.2.1 From 974c7646ec5b2985a50007c9d599154d667df349 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 14 Feb 2013 14:08:38 -0800 Subject: Backport GCPRO fix from trunk. The bug was reported for AIX before today's changes. I reproduced the problem on Fedora 17 x86-64 when setting GC_MARK_STACK by hand, and I presume it occurs with default configurations on HP-UX and Unixware. Trunk fix on 2013-01-14 by Dmitry Antipov : Fix compilation with GC_MARK_STACK == GC_USE_GCPROS_AS_BEFORE. * eval.c (eval_sub): Protect `form' from being GCed before its car and cdr becomes protected with the backtrace entry. Fixes: debbugs:13650 --- src/ChangeLog | 10 ++++++++++ src/eval.c | 3 +++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index e283d2bb48c..46a466d060d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,15 @@ 2013-02-14 Paul Eggert + Backport GCPRO fix from trunk (Bug#13650). + The bug was reported for AIX before today's changes. + I reproduced the problem on Fedora 17 x86-64 when setting + GC_MARK_STACK by hand, and I presume it occurs with default + configurations on HP-UX and Unixware. + Trunk fix on 2013-01-14 by Dmitry Antipov : + Fix compilation with GC_MARK_STACK == GC_USE_GCPROS_AS_BEFORE. + * eval.c (eval_sub): Protect `form' from being GCed before its + car and cdr becomes protected with the backtrace entry. + Fix AIX port (Bug#13650). * lisp.h (XPNTR) [!USE_LSB_TAG && DATA_SEG_BITS]: Fix bug introduced in 2012-07-27 change. DATA_SEG_BITS, if set, diff --git a/src/eval.c b/src/eval.c index a0db6e0745c..a21b2b05762 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2034,7 +2034,10 @@ eval_sub (Lisp_Object form) return form; QUIT; + + GCPRO1 (form); maybe_gc (); + UNGCPRO; if (++lisp_eval_depth > max_lisp_eval_depth) { -- cgit v1.2.1 From bcf7fe2aeff7e3aacbfae08ca6001f7615a06709 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 15 Feb 2013 11:01:13 +0200 Subject: Improve error reporting as part of solving bug #13546 on MS-Windows. src/w32.c (sys_socket, sys_bind, sys_connect, sys_gethostname) (sys_gethostbyname, sys_getservbyname, sys_getpeername) (sys_shutdown, sys_setsockopt, sys_listen, sys_getsockname) (sys_accept, sys_recvfrom, sys_sendto, fcntl): In case of failure, make sure errno is set to an appropriate value. (Bug#13546) (socket_to_fd): Add assertion against indexing fd_info[] with a value that is out of bounds. (sys_accept): If fd is negative, do not set up the child_process structure for reading. --- src/ChangeLog | 12 ++++++++++ src/w32.c | 74 +++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 56 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 46a466d060d..47a55535870 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2013-02-15 Eli Zaretskii + + * w32.c (sys_socket, sys_bind, sys_connect, sys_gethostname) + (sys_gethostbyname, sys_getservbyname, sys_getpeername) + (sys_shutdown, sys_setsockopt, sys_listen, sys_getsockname) + (sys_accept, sys_recvfrom, sys_sendto, fcntl): In case of failure, + make sure errno is set to an appropriate value. (Bug#13546) + (socket_to_fd): Add assertion against indexing fd_info[] with a + value that is out of bounds. + (sys_accept): If fd is negative, do not set up the child_process + structure for reading. + 2013-02-14 Paul Eggert Backport GCPRO fix from trunk (Bug#13650). diff --git a/src/w32.c b/src/w32.c index 214fb7fdfae..dbb090d61f9 100644 --- a/src/w32.c +++ b/src/w32.c @@ -5655,7 +5655,7 @@ sys_socket (int af, int type, int protocol) if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return INVALID_SOCKET; } @@ -5665,7 +5665,13 @@ sys_socket (int af, int type, int protocol) s = pfn_socket (af, type, protocol); if (s != INVALID_SOCKET) - return socket_to_fd (s); + { + int retval = socket_to_fd (s); + + if (retval == -1) + errno = h_errno; + return retval; + } set_errno (); return -1; @@ -5732,6 +5738,7 @@ socket_to_fd (SOCKET s) } } } + eassert (fd < MAXDESC); fd_info[fd].hnd = (HANDLE) s; /* set our own internal flags */ @@ -5770,7 +5777,7 @@ sys_bind (int s, const struct sockaddr * addr, int namelen) { if (winsock_lib == NULL) { - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -5782,7 +5789,7 @@ sys_bind (int s, const struct sockaddr * addr, int namelen) set_errno (); return rc; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -5791,7 +5798,7 @@ sys_connect (int s, const struct sockaddr * name, int namelen) { if (winsock_lib == NULL) { - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -5803,7 +5810,7 @@ sys_connect (int s, const struct sockaddr * name, int namelen) set_errno (); return rc; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -5837,7 +5844,7 @@ sys_gethostname (char * name, int namelen) if (namelen > MAX_COMPUTERNAME_LENGTH) return !GetComputerName (name, (DWORD *)&namelen); - h_errno = EFAULT; + errno = h_errno = EFAULT; return SOCKET_ERROR; } @@ -5848,7 +5855,7 @@ sys_gethostbyname (const char * name) if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return NULL; } @@ -5866,7 +5873,7 @@ sys_getservbyname (const char * name, const char * proto) if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return NULL; } @@ -5882,7 +5889,7 @@ sys_getpeername (int s, struct sockaddr *addr, int * namelen) { if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return SOCKET_ERROR; } @@ -5894,7 +5901,7 @@ sys_getpeername (int s, struct sockaddr *addr, int * namelen) set_errno (); return rc; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -5903,7 +5910,7 @@ sys_shutdown (int s, int how) { if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return SOCKET_ERROR; } @@ -5915,7 +5922,7 @@ sys_shutdown (int s, int how) set_errno (); return rc; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -5924,7 +5931,7 @@ sys_setsockopt (int s, int level, int optname, const void * optval, int optlen) { if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return SOCKET_ERROR; } @@ -5937,7 +5944,7 @@ sys_setsockopt (int s, int level, int optname, const void * optval, int optlen) set_errno (); return rc; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -5946,7 +5953,7 @@ sys_listen (int s, int backlog) { if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return SOCKET_ERROR; } @@ -5960,7 +5967,7 @@ sys_listen (int s, int backlog) fd_info[s].flags |= FILE_LISTEN; return rc; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -5969,7 +5976,7 @@ sys_getsockname (int s, struct sockaddr * name, int * namelen) { if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return SOCKET_ERROR; } @@ -5981,7 +5988,7 @@ sys_getsockname (int s, struct sockaddr * name, int * namelen) set_errno (); return rc; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -5990,7 +5997,7 @@ sys_accept (int s, struct sockaddr * addr, int * addrlen) { if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return -1; } @@ -6002,13 +6009,20 @@ sys_accept (int s, struct sockaddr * addr, int * addrlen) if (t == INVALID_SOCKET) set_errno (); else - fd = socket_to_fd (t); + { + fd = socket_to_fd (t); + if (fd < 0) + errno = h_errno; /* socket_to_fd sets h_errno */ + } - fd_info[s].cp->status = STATUS_READ_ACKNOWLEDGED; - ResetEvent (fd_info[s].cp->char_avail); + if (fd >= 0) + { + fd_info[s].cp->status = STATUS_READ_ACKNOWLEDGED; + ResetEvent (fd_info[s].cp->char_avail); + } return fd; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return -1; } @@ -6018,7 +6032,7 @@ sys_recvfrom (int s, char * buf, int len, int flags, { if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return SOCKET_ERROR; } @@ -6030,7 +6044,7 @@ sys_recvfrom (int s, char * buf, int len, int flags, set_errno (); return rc; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -6040,7 +6054,7 @@ sys_sendto (int s, const char * buf, int len, int flags, { if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return SOCKET_ERROR; } @@ -6052,7 +6066,7 @@ sys_sendto (int s, const char * buf, int len, int flags, set_errno (); return rc; } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } @@ -6063,7 +6077,7 @@ fcntl (int s, int cmd, int options) { if (winsock_lib == NULL) { - h_errno = ENETDOWN; + errno = h_errno = ENETDOWN; return -1; } @@ -6086,7 +6100,7 @@ fcntl (int s, int cmd, int options) return SOCKET_ERROR; } } - h_errno = ENOTSOCK; + errno = h_errno = ENOTSOCK; return SOCKET_ERROR; } -- cgit v1.2.1 From ef862e206a28f6618048c8b28413fa8f9c135c61 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 15 Feb 2013 11:41:31 +0200 Subject: Allow deleted processes to be reaped by SIGCHLD handler on MS-Windows. src/w32proc.c (new_child): Free up to 2 slots of dead processes at a time. Improve diagnostics in DebPrint. (reader_thread): If cp->char_avail is NULL, set the FILE_AT_EOF flag, so that sys_select could have a chance of noticing that this process is dead, and call a SIGCHLD handler for it. Improve diagnostics in DebPrint. (reap_subprocess): Reset the FILE_AT_EOF flag set by reader_thread. (sys_select): Watch a process whose procinfo.hProcess is non-NULL even if its char_avail is NULL. Allows to reap subprocesses that were forcibly deleted by delete-process. (Bug#13546) --- src/ChangeLog | 12 ++++++++++++ src/w32proc.c | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 47a55535870..f4bee9f0905 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,17 @@ 2013-02-15 Eli Zaretskii + * w32proc.c (new_child): Free up to 2 slots of dead processes at a + time. Improve diagnostics in DebPrint. + (reader_thread): If cp->char_avail is NULL, set the FILE_AT_EOF + flag, so that sys_select could have a chance of noticing that this + process is dead, and call a SIGCHLD handler for it. Improve + diagnostics in DebPrint. + (reap_subprocess): Reset the FILE_AT_EOF flag set by + reader_thread. + (sys_select): Watch a process whose procinfo.hProcess is non-NULL + even if its char_avail is NULL. Allows to reap subprocesses that + were forcibly deleted by delete-process. (Bug#13546) + * w32.c (sys_socket, sys_bind, sys_connect, sys_gethostname) (sys_gethostbyname, sys_getservbyname, sys_getpeername) (sys_shutdown, sys_setsockopt, sys_listen, sys_getsockname) diff --git a/src/w32proc.c b/src/w32proc.c index 1e72d41e16b..e9860a66468 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -799,6 +799,9 @@ new_child (void) goto Initialize; if (child_proc_count == MAX_CHILDREN) { + int i = 0; + child_process *dead_cp; + DebPrint (("new_child: No vacant slots, looking for dead processes\n")); for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess) @@ -814,13 +817,23 @@ new_child (void) if (status != STILL_ACTIVE || WaitForSingleObject (cp->procinfo.hProcess, 0) == WAIT_OBJECT_0) { - DebPrint (("new_child: Freeing slot of dead process %d\n", - cp->procinfo.dwProcessId)); + DebPrint (("new_child: Freeing slot of dead process %d, fd %d\n", + cp->procinfo.dwProcessId, cp->fd)); CloseHandle (cp->procinfo.hProcess); cp->procinfo.hProcess = NULL; CloseHandle (cp->procinfo.hThread); cp->procinfo.hThread = NULL; - goto Initialize; + /* Free up to 2 dead slots at a time, so that if we + have a lot of them, they will eventually all be + freed when the tornado ends. */ + if (i == 0) + dead_cp = cp; + else + { + cp = dead_cp; + goto Initialize; + } + i++; } } } @@ -975,12 +988,24 @@ reader_thread (void *arg) else rc = _sys_read_ahead (cp->fd); + if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess && cp->fd >= 0) + { + /* Somebody already called delete_child on this child, since + only delete_child zeroes out cp->char_avail. This means + no one will read from cp->fd and will not set the + FILE_AT_EOF flag, therefore preventing sys_select from + noticing that the process died. Set the flag here + instead. */ + fd_info[cp->fd].flags |= FILE_AT_EOF; + } + /* The name char_avail is a misnomer - it really just means the read-ahead has completed, whether successfully or not. */ if (!SetEvent (cp->char_avail)) { - DebPrint (("reader_thread.SetEvent failed with %lu for fd %ld\n", - GetLastError (), cp->fd)); + DebPrint (("reader_thread.SetEvent(0x%x) failed with %lu for fd %ld (PID %d)\n", + (DWORD_PTR)cp->char_avail, GetLastError (), + cp->fd, cp->pid)); return 1; } @@ -1141,6 +1166,11 @@ reap_subprocess (child_process *cp) register_child has not been called. */ if (cp->fd == -1) delete_child (cp); + else + { + /* Reset the flag set by reader_thread. */ + fd_info[cp->fd].flags &= ~FILE_AT_EOF; + } } /* Wait for any of our existing child processes to die @@ -1925,7 +1955,7 @@ count_children: /* Some child_procs might be sockets; ignore them. Also some children may have died already, but we haven't finished reading the process output; ignore them too. */ - if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess + if ((CHILD_ACTIVE (cp) || cp->procinfo.hProcess) && (cp->fd < 0 || (fd_info[cp->fd].flags & FILE_SEND_SIGCHLD) == 0 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0) -- cgit v1.2.1 From 0063fdb148db6352a06448053227c0924110cdda Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 15 Feb 2013 16:26:42 +0400 Subject: * composite.c (fill_gstring_header): Remove useless prototype. Break long line. * lisp.h (message_dolog, compile_pattern): Adjust prototype. * print.c (PRINTDECLARE, print_object): * search.c (compile_pattern, fast_looking_at, search_buffer): (simple_search, boyer_moore, Freplace_match): * xdisp.c (c_string_pos, number_of_chars, message_dolog): (get_overlay_arrow_glyph_row, display_mode_element): (decode_mode_spec_coding, message3): * xfaces.c (face_at_string_position): Use bool for booleans. Adjust comments. --- src/ChangeLog | 14 ++++++++++++++ src/composite.c | 7 ++----- src/lisp.h | 4 ++-- src/print.c | 5 +++-- src/search.c | 20 +++++++++++--------- src/xdisp.c | 22 +++++++++++----------- src/xfaces.c | 2 +- 7 files changed, 44 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 00cb40df9e6..448f1e1ca0f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2013-02-15 Dmitry Antipov + + * composite.c (fill_gstring_header): Remove useless prototype. + Break long line. + * lisp.h (message_dolog, compile_pattern): Adjust prototype. + * print.c (PRINTDECLARE, print_object): + * search.c (compile_pattern, fast_looking_at, search_buffer): + (simple_search, boyer_moore, Freplace_match): + * xdisp.c (c_string_pos, number_of_chars, message_dolog): + (get_overlay_arrow_glyph_row, display_mode_element): + (decode_mode_spec_coding, message3): + * xfaces.c (face_at_string_position): Use bool for booleans. + Adjust comments. + 2013-02-15 Paul Eggert Fix AIX port (Bug#13650). diff --git a/src/composite.c b/src/composite.c index 9bbd4550c7b..2da98cfc36c 100644 --- a/src/composite.c +++ b/src/composite.c @@ -698,10 +698,6 @@ composition_gstring_from_id (ptrdiff_t id) return HASH_VALUE (h, id); } -static Lisp_Object fill_gstring_header (Lisp_Object, Lisp_Object, - Lisp_Object, Lisp_Object, - Lisp_Object); - bool composition_gstring_p (Lisp_Object gstring) { @@ -791,7 +787,8 @@ static Lisp_Object gstring_work; static Lisp_Object gstring_work_headers; static Lisp_Object -fill_gstring_header (Lisp_Object header, Lisp_Object start, Lisp_Object end, Lisp_Object font_object, Lisp_Object string) +fill_gstring_header (Lisp_Object header, Lisp_Object start, Lisp_Object end, + Lisp_Object font_object, Lisp_Object string) { ptrdiff_t from, to, from_byte; ptrdiff_t len, i; diff --git a/src/lisp.h b/src/lisp.h index da1531cc1be..44a5bd571ff 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2953,7 +2953,7 @@ extern void message1 (const char *); extern void message1_nolog (const char *); extern void message3 (Lisp_Object); extern void message3_nolog (Lisp_Object); -extern void message_dolog (const char *, ptrdiff_t, int, int); +extern void message_dolog (const char *, ptrdiff_t, bool, bool); extern void message_with_string (const char *, Lisp_Object, int); extern void message_log_maybe_newline (void); extern void update_echo_area (void); @@ -3335,7 +3335,7 @@ extern void record_unwind_save_match_data (void); struct re_registers; extern struct re_pattern_buffer *compile_pattern (Lisp_Object, struct re_registers *, - Lisp_Object, int, int); + Lisp_Object, int, bool); extern ptrdiff_t fast_string_match (Lisp_Object, Lisp_Object); extern ptrdiff_t fast_c_string_match_ignore_case (Lisp_Object, const char *, ptrdiff_t); diff --git a/src/print.c b/src/print.c index 24886a64914..4aae4118152 100644 --- a/src/print.c +++ b/src/print.c @@ -102,7 +102,8 @@ int print_output_debug_flag EXTERNALLY_VISIBLE = 1; ptrdiff_t old_point_byte = -1, start_point_byte = -1; \ ptrdiff_t specpdl_count = SPECPDL_INDEX (); \ int free_print_buffer = 0; \ - int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); \ + bool multibyte \ + = !NILP (BVAR (current_buffer, enable_multibyte_characters)); \ Lisp_Object original #define PRINTPREPARE \ @@ -1396,7 +1397,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag /* 1 means we must ensure that the next character we output cannot be taken as part of a hex character escape. */ int need_nonhex = 0; - int multibyte = STRING_MULTIBYTE (obj); + bool multibyte = STRING_MULTIBYTE (obj); GCPRO1 (obj); diff --git a/src/search.c b/src/search.c index c25d2441018..d4508004bf6 100644 --- a/src/search.c +++ b/src/search.c @@ -209,7 +209,8 @@ clear_regexp_cache (void) for this pattern. 0 means backtrack only enough to get a valid match. */ struct re_pattern_buffer * -compile_pattern (Lisp_Object pattern, struct re_registers *regp, Lisp_Object translate, int posix, int multibyte) +compile_pattern (Lisp_Object pattern, struct re_registers *regp, + Lisp_Object translate, int posix, bool multibyte) { struct regexp_cache *cp, **cpp; @@ -534,9 +535,10 @@ fast_string_match_ignore_case (Lisp_Object regexp, Lisp_Object string) data. */ ptrdiff_t -fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t limit, ptrdiff_t limit_byte, Lisp_Object string) +fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte, + ptrdiff_t limit, ptrdiff_t limit_byte, Lisp_Object string) { - int multibyte; + bool multibyte; struct re_pattern_buffer *buf; unsigned char *p1, *p2; ptrdiff_t s1, s2; @@ -1248,7 +1250,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t raw_pattern_size; ptrdiff_t raw_pattern_size_byte; unsigned char *patbuf; - int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); + bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); unsigned char *base_pat; /* Set to positive if we find a non-ASCII char that need translation. Otherwise set to zero later. */ @@ -1461,8 +1463,8 @@ simple_search (EMACS_INT n, unsigned char *pat, ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t lim, ptrdiff_t lim_byte) { - int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); - int forward = n > 0; + bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); + bool forward = n > 0; /* Number of buffer bytes matched. Note that this may be different from len_byte in a multibyte buffer. */ ptrdiff_t match_byte = PTRDIFF_MIN; @@ -1681,7 +1683,7 @@ boyer_moore (EMACS_INT n, unsigned char *base_pat, register ptrdiff_t i; register int j; unsigned char *pat, *pat_end; - int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); + bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); unsigned char simple_translate[0400]; /* These are set to the preceding bytes of a byte to be translated @@ -2507,8 +2509,8 @@ since only regular expressions have distinguished subexpressions. */) ptrdiff_t length = SBYTES (newtext); unsigned char *substed; ptrdiff_t substed_alloc_size, substed_len; - int buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); - int str_multibyte = STRING_MULTIBYTE (newtext); + bool buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); + bool str_multibyte = STRING_MULTIBYTE (newtext); int really_changed = 0; substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length diff --git a/src/xdisp.c b/src/xdisp.c index d2d4b3bbb79..c41b7f3c8cb 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -910,8 +910,8 @@ static int forward_to_next_line_start (struct it *, int *, struct bidi_it *); static struct text_pos string_pos_nchars_ahead (struct text_pos, Lisp_Object, ptrdiff_t); static struct text_pos string_pos (ptrdiff_t, Lisp_Object); -static struct text_pos c_string_pos (ptrdiff_t, const char *, int); -static ptrdiff_t number_of_chars (const char *, int); +static struct text_pos c_string_pos (ptrdiff_t, const char *, bool); +static ptrdiff_t number_of_chars (const char *, bool); static void compute_stop_pos (struct it *); static void compute_string_pos (struct text_pos *, struct text_pos, Lisp_Object); @@ -1650,7 +1650,7 @@ string_pos (ptrdiff_t charpos, Lisp_Object string) means recognize multibyte characters. */ static struct text_pos -c_string_pos (ptrdiff_t charpos, const char *s, int multibyte_p) +c_string_pos (ptrdiff_t charpos, const char *s, bool multibyte_p) { struct text_pos pos; @@ -1681,7 +1681,7 @@ c_string_pos (ptrdiff_t charpos, const char *s, int multibyte_p) non-zero means recognize multibyte characters. */ static ptrdiff_t -number_of_chars (const char *s, int multibyte_p) +number_of_chars (const char *s, bool multibyte_p) { ptrdiff_t nchars; @@ -9357,8 +9357,8 @@ message_log_maybe_newline (void) /* Add a string M of length NBYTES to the message log, optionally - terminated with a newline when NLFLAG is non-zero. MULTIBYTE, if - nonzero, means interpret the contents of M as multibyte. This + terminated with a newline when NLFLAG is true. MULTIBYTE, if + true, means interpret the contents of M as multibyte. This function calls low-level routines in order to bypass text property hooks, etc. which might not be safe to run. @@ -9366,7 +9366,7 @@ message_log_maybe_newline (void) so the buffer M must NOT point to a Lisp string. */ void -message_dolog (const char *m, ptrdiff_t nbytes, int nlflag, int multibyte) +message_dolog (const char *m, ptrdiff_t nbytes, bool nlflag, bool multibyte) { const unsigned char *msg = (const unsigned char *) m; @@ -9591,7 +9591,7 @@ message3 (Lisp_Object m) if (STRINGP (m)) { ptrdiff_t nbytes = SBYTES (m); - int multibyte = STRING_MULTIBYTE (m); + bool multibyte = STRING_MULTIBYTE (m); USE_SAFE_ALLOCA; char *buffer = SAFE_ALLOCA (nbytes); memcpy (buffer, SDATA (m), nbytes); @@ -18064,7 +18064,7 @@ get_overlay_arrow_glyph_row (struct window *w, Lisp_Object overlay_arrow_string) const unsigned char *arrow_end = arrow_string + arrow_len; const unsigned char *p; struct it it; - int multibyte_p; + bool multibyte_p; int n_glyphs_before; set_buffer_temp (buffer); @@ -20495,7 +20495,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision, risky); else if (c != 0) { - int multibyte; + bool multibyte; ptrdiff_t bytepos, charpos; const char *spec; Lisp_Object string; @@ -21100,7 +21100,7 @@ static char * decode_mode_spec_coding (Lisp_Object coding_system, register char *buf, int eol_flag) { Lisp_Object val; - int multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); + bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); const unsigned char *eol_str; int eol_str_len; /* The EOL conversion we are using. */ diff --git a/src/xfaces.c b/src/xfaces.c index 33a221fdd52..71709446c1d 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -6152,7 +6152,7 @@ face_at_string_position (struct window *w, Lisp_Object string, struct frame *f = XFRAME (WINDOW_FRAME (w)); Lisp_Object attrs[LFACE_VECTOR_SIZE]; struct face *base_face; - int multibyte_p = STRING_MULTIBYTE (string); + bool multibyte_p = STRING_MULTIBYTE (string); Lisp_Object prop_name = mouse_p ? Qmouse_face : Qface; /* Get the value of the face property at the current position within -- cgit v1.2.1 From a7727d05be4047b4ab6c8218ad2de5e2ad8624da Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 15 Feb 2013 15:14:26 +0200 Subject: Fix commit 2013-02-15T09:41:31Z!eliz@gnu.org for bug #13546. --- src/w32proc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/w32proc.c b/src/w32proc.c index e9860a66468..ca2096aaa9d 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -800,7 +800,7 @@ new_child (void) if (child_proc_count == MAX_CHILDREN) { int i = 0; - child_process *dead_cp; + child_process *dead_cp = NULL; DebPrint (("new_child: No vacant slots, looking for dead processes\n")); for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) @@ -829,13 +829,15 @@ new_child (void) if (i == 0) dead_cp = cp; else - { - cp = dead_cp; - goto Initialize; - } + break; i++; } } + if (dead_cp) + { + cp = dead_cp; + goto Initialize; + } } if (child_proc_count == MAX_CHILDREN) return NULL; -- cgit v1.2.1 From ef9c57e27aad0105ec058cc68377460763438af4 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 15 Feb 2013 20:52:16 +0200 Subject: Fix bug #13720 with auto-save-timeout less than 4 seconds. src/keyboard.c (read_char): Fix calculation of auto-save time out when auto-save-timeout is less than 4. --- src/ChangeLog | 3 +++ src/keyboard.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 1e1fe641ee5..1175e97688d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2013-02-15 Eli Zaretskii + * keyboard.c (read_char): Fix calculation of auto-save time out + when auto-save-timeout is less than 4. (Bug#13720) + * w32proc.c (new_child): Free up to 2 slots of dead processes at a time. Improve diagnostics in DebPrint. (reader_thread): If cp->char_avail is NULL, set the FILE_AT_EOF diff --git a/src/keyboard.c b/src/keyboard.c index fe1c3d77eb6..69c68d13943 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2657,9 +2657,10 @@ read_char (int commandflag, Lisp_Object map, && XINT (Vauto_save_timeout) > 0) { Lisp_Object tem0; - EMACS_INT timeout = (delay_level - * min (XFASTINT (Vauto_save_timeout) / 4, - MOST_POSITIVE_FIXNUM / delay_level)); + EMACS_INT timeout = XFASTINT (Vauto_save_timeout); + + timeout = min (timeout, MOST_POSITIVE_FIXNUM / delay_level * 4); + timeout = delay_level * timeout / 4; save_getcjmp (save_jump); restore_getcjmp (local_getcjmp); tem0 = sit_for (make_number (timeout), 1, 1); -- cgit v1.2.1 From e454145b0985d28ef5581be5c469726e68762322 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 15 Feb 2013 11:08:11 -0800 Subject: * process.c (h_errno) [!HAVE_H_ERRNO]: Remove unused decl. --- src/ChangeLog | 4 ++++ src/process.c | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 1175e97688d..82751e371df 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2013-02-15 Paul Eggert + + * process.c (h_errno) [!HAVE_H_ERRNO]: Remove unused decl. + 2013-02-15 Eli Zaretskii * keyboard.c (read_char): Fix calculation of auto-save time out diff --git a/src/process.c b/src/process.c index f210065b98e..9d6e8c097a1 100644 --- a/src/process.c +++ b/src/process.c @@ -180,10 +180,6 @@ static Lisp_Object Qlast_nonmenu_event; #define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) #define SERIALCONN1_P(p) (EQ (p->type, Qserial)) -#ifndef HAVE_H_ERRNO -extern int h_errno; -#endif - /* Number of events of change of status of a process. */ static EMACS_INT process_tick; /* Number of events for which the user or sentinel has been notified. */ @@ -5567,7 +5563,7 @@ Output from processes can arrive in between bunches. */) if (XINT (start) < GPT && XINT (end) > GPT) move_gap_both (XINT (start), start_byte); - send_process (proc, (char *) BYTE_POS_ADDR (start_byte), + send_process (proc, (char *) BYTE_POS_ADDR (start_byte), end_byte - start_byte, Fcurrent_buffer ()); return Qnil; -- cgit v1.2.1 From b2af991a2ff353b27fd6f72785e0081a742fd88a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 15 Feb 2013 21:37:29 +0200 Subject: Remove unneeded bits of commit 2013-02-15T09:41:31Z!eliz@gnu.org merged from release branch. --- src/ChangeLog | 11 +---------- src/w32proc.c | 18 +----------------- 2 files changed, 2 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 82751e371df..6ff25edac50 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -8,16 +8,7 @@ when auto-save-timeout is less than 4. (Bug#13720) * w32proc.c (new_child): Free up to 2 slots of dead processes at a - time. Improve diagnostics in DebPrint. - (reader_thread): If cp->char_avail is NULL, set the FILE_AT_EOF - flag, so that sys_select could have a chance of noticing that this - process is dead, and call a SIGCHLD handler for it. Improve - diagnostics in DebPrint. - (reap_subprocess): Reset the FILE_AT_EOF flag set by - reader_thread. - (sys_select): Watch a process whose procinfo.hProcess is non-NULL - even if its char_avail is NULL. Allows to reap subprocesses that - were forcibly deleted by delete-process. (Bug#13546) + time. Improve diagnostics in DebPrint. (Bug#13546) * w32.c (sys_socket, sys_bind, sys_connect, sys_gethostname) (sys_gethostbyname, sys_getservbyname, sys_getpeername) diff --git a/src/w32proc.c b/src/w32proc.c index 8226564c88f..3f3e97c77a0 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -1017,17 +1017,6 @@ reader_thread (void *arg) if (cp->status == STATUS_READ_ERROR || !cp->char_avail) break; - if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess && cp->fd >= 0) - { - /* Somebody already called delete_child on this child, since - only delete_child zeroes out cp->char_avail. This means - no one will read from cp->fd and will not set the - FILE_AT_EOF flag, therefore preventing sys_select from - noticing that the process died. Set the flag here - instead. */ - fd_info[cp->fd].flags |= FILE_AT_EOF; - } - /* The name char_avail is a misnomer - it really just means the read-ahead has completed, whether successfully or not. */ if (!SetEvent (cp->char_avail)) @@ -1237,11 +1226,6 @@ reap_subprocess (child_process *cp) sys_read when the subprocess output is fully read. */ if (cp->fd < 0) delete_child (cp); - else - { - /* Reset the flag set by reader_thread. */ - fd_info[cp->fd].flags &= ~FILE_AT_EOF; - } } /* Wait for a child process specified by PID, or for any of our @@ -2067,7 +2051,7 @@ count_children: /* Some child_procs might be sockets; ignore them. Also some children may have died already, but we haven't finished reading the process output; ignore them too. */ - if ((CHILD_ACTIVE (cp) || cp->procinfo.hProcess) + if ((CHILD_ACTIVE (cp) && cp->procinfo.hProcess) && (cp->fd < 0 || (fd_info[cp->fd].flags & FILE_SEND_SIGCHLD) == 0 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0) -- cgit v1.2.1