aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2012-11-18 20:29:54 +0900
committerKenichi Handa2012-11-18 20:29:54 +0900
commite1d276cbf9e18f13101328f56bed1a1c0a66e63a (patch)
treef1fdfc9550866b9e323da072ff2eb38821996246 /src
parent00dc3ead070e2e8017629f4d60d8366ac00c32cb (diff)
parentdfa8939b2827d23e02f3d7f6622e3a619ec6fd90 (diff)
downloademacs-e1d276cbf9e18f13101328f56bed1a1c0a66e63a.tar.gz
emacs-e1d276cbf9e18f13101328f56bed1a1c0a66e63a.zip
merge trunk
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog148
-rw-r--r--src/callproc.c11
-rw-r--r--src/editfns.c4
-rw-r--r--src/emacs.c4
-rw-r--r--src/eval.c4
-rw-r--r--src/keyboard.c4
-rw-r--r--src/makefile.w32-in12
-rw-r--r--src/nsterm.m36
-rw-r--r--src/process.c114
-rw-r--r--src/sysdep.c33
-rw-r--r--src/term.c39
-rw-r--r--src/unexelf.c2
-rw-r--r--src/w32.c35
-rw-r--r--src/w32proc.c166
-rw-r--r--src/w32select.c2
-rw-r--r--src/w32term.h15
-rw-r--r--src/xfaces.c8
17 files changed, 374 insertions, 263 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d7699def9a5..6dcddea2e63 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -8,6 +8,154 @@
8 * font.c (font_unparse_xlfd): Exclude special characters from the 8 * font.c (font_unparse_xlfd): Exclude special characters from the
9 generating XLFD name. 9 generating XLFD name.
10 10
112012-11-18 Paul Eggert <eggert@cs.ucla.edu>
12
13 * nsterm.m (ns_select): Send SIGIO only to self, not to process group.
14
152012-11-18 Eli Zaretskii <eliz@gnu.org>
16
17 * w32select.c: Include w32common.h before w32term.h, so that
18 windows.h gets included before w32term.h uses some of its
19 features, see below.
20
21 * w32term.h (LOCALE_ENUMPROCA, LOCALE_ENUMPROCW) [_MSC_VER]: New
22 typedefs.
23 (EnumSystemLocalesA, EnumSystemLocalesW) [_MSC_VER]: New
24 prototypes.
25 (EnumSystemLocales) [_MSC_VER]: Define if undefined. (Bug#12878)
26
272012-11-18 Jan Djärv <jan.h.d@swipnet.se>
28
29 * nsterm.m (hold_event): Set send_appdefined to YES (Bug#12834).
30 (ns_select): Return at once if events are held (Bug#12834).
31
322012-11-18 enami tsugutomo <tsugutomo.enami@jp.sony.com>
33
34 * unexelf.c (ELFSIZE) [__NetBSD__ && _LP64]: Set to 64.
35 Needed following 2012-10-20 change. (Bug#12902)
36
372012-11-18 Juanma Barranquero <lekktu@gmail.com>
38
39 * w32proc.c (waitpid): Remove unused label get_result.
40
412012-11-17 Juanma Barranquero <lekktu@gmail.com>
42
43 * makefile.w32-in (SYSWAIT_H): New macro.
44 ($(BLD)/callproc.$(O), $(BLD)/w32proc.$(O), $(BLD)/process.$(O))
45 ($(BLD)/sysdep.$(O)): Update dependencies.
46
472012-11-17 Paul Eggert <eggert@cs.ucla.edu>
48
49 Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881).
50 * callproc.c (relocate_fd): Assume F_DUPFD.
51 * emacs.c, term.c (O_RDWR): Remove.
52 * keyboard.c (tty_read_avail_input): Use O_NONBLOCK rather than
53 O_NDELAY, since O_NONBLOCK is the standard name for this flag.
54 * nsterm.m: Assume <fcntl.h> exists.
55 * process.c (NON_BLOCKING_CONNECT, allocate_pty, create_process)
56 (create_pty, Fmake_network_process, server_accept_connection)
57 (wait_reading_process_output, init_process_emacs):
58 Assume O_NONBLOCK.
59 (wait_reading_process_output): Put in a special case for WINDOWSNT
60 to mimick the older behavior where it had O_NDELAY but not O_NONBLOCK.
61 It's not clear this is needed, but it's a more-conservative change.
62 (create_process): Assume FD_CLOEXEC.
63 (create_process, create_pty): Assume O_NOCTTY.
64 * sysdep.c (init_sys_modes, reset_sys_modes): Assume F_SETFL.
65 (reset_sys_modes): Use O_NONBLOCK rather than O_NDELAY.
66 Omit if not DOS_NT, since F_GETFL is not defined there.
67 (serial_open): Assume O_NONBLOCK and O_NOCTTY.
68 * term.c: Include <fcntl.h>, for flags like O_NOCTTY.
69 (O_NOCTTY): Remove.
70 (init_tty): Assume O_IGNORE_CTTY is defined to 0 on platforms that
71 lack it, since gnulib guarantees this.
72 * w32.c (fcntl): Test for O_NONBLOCK rather than O_NDELAY.
73
742012-11-17 Eli Zaretskii <eliz@gnu.org>
75
76 * w32.c (faccessat): Pretend that directories have the execute bit
77 set. Emacs expects that, e.g., in files.el:cd-absolute.
78
79 * w32proc.c (create_child): Don't clip the PID of the child
80 process to fit into an Emacs integer, as this is no longer a
81 restriction.
82 (waitpid): Rename from sys_wait. Emulate a Posix 'waitpid' by
83 reaping only the process specified by PID argument, if that is
84 positive. Use PID instead of dead_child to know which process to
85 reap. Wait for the child to die only if WNOHANG is not in
86 OPTIONS.
87 (sys_select): Don't set dead_child.
88
89 * sysdep.c (wait_for_termination_1): Remove the WINDOWSNT portion,
90 as it is no longer needed.
91
92 * process.c (waitpid, WUNTRACED) [!WNOHANG]: Remove definitions,
93 no longer needed.
94 (record_child_status_change): Remove the setting of
95 record_at_most_one_child for the !WNOHANG case.
96
972012-11-17 Paul Eggert <eggert@cs.ucla.edu>
98
99 Fix problems in ns port found by static checking.
100 * nsterm.m: Include <pthread.h>, for pthread_mutex_lock etc.
101 (hold_event, setPosition:portion:whole:): Send SIGIO only to self,
102 not to process group.
103 (ns_select): Use emacs_write, not write, as that's more robust
104 in the presence of signals.
105 (fd_handler:): Check for read errors.
106
1072012-11-16 Glenn Morris <rgm@gnu.org>
108
109 * editfns.c (Fmessage): Mention message-log-max. (Bug#12849)
110
1112012-11-16 Stefan Monnier <monnier@iro.umontreal.ca>
112
113 * eval.c (Finteractive_p): Revert lexbind-merge mishap.
114
1152012-11-16 Eli Zaretskii <eliz@gnu.org>
116
117 * w32proc.c (timer_loop): Make sure SuspendThread and ResumeThread
118 use the same value of thread handle.
119 (start_timer_thread): If the timer thread exited (due to error),
120 clean up by closing the two handles it used. Duplicate the caller
121 thread's handle here, so it gets duplicated only once, when
122 launching the timer thread. Set priority of the timer thread, not
123 the caller thread.
124 (getitimer): Don't duplicate the caller thread's handle here.
125 (Bug#12832)
126
1272012-11-16 Jan Djärv <jan.h.d@swipnet.se>
128
129 * nsterm.m (hold_event): Send SIGIO to make sure ns_read_socket is
130 called (Bug#12834).
131
1322012-11-16 Paul Eggert <eggert@cs.ucla.edu>
133
134 Remove no-longer-used pty_max_bytes variable.
135 * process.c (pty_max_bytes): Remove; unused.
136 (send_process): Do not set it.
137
1382012-11-15 Juanma Barranquero <lekktu@gmail.com>
139
140 * makefile.w32-in ($(BLD)/dispnew.$(O), $(BLD)/emacs.$(O)):
141 Update dependencies.
142
1432012-11-15 Paul Eggert <eggert@cs.ucla.edu>
144
145 * eval.c (mark_backtrace) [BYTE_MARK_STACK]: Remove stray '*'.
146 This follows up on the 2012-09-29 patch that removed indirection
147 for the 'function' field. Reported by Sergey Vinokurov in
148 <http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00263.html>.
149
1502012-11-14 Eli Zaretskii <eliz@gnu.org>
151
152 * w32.c (faccessat): Rename from sys_faccessat. (No need to use a
153 different name, as the MS runtime does not have such a function,
154 and probably never will.) All callers changed. Ignore DIRFD
155 value if PATH is an absolute file name, to match Posix spec
156 better. If AT_SYMLINK_NOFOLLOW is set in FLAGS, don't resolve
157 symlinks.
158
112012-11-14 Dmitry Antipov <dmantipov@yandex.ru> 1592012-11-14 Dmitry Antipov <dmantipov@yandex.ru>
12 160
13 * xdisp.c (echo_area_display, redisplay_internal): 161 * xdisp.c (echo_area_display, redisplay_internal):
diff --git a/src/callproc.c b/src/callproc.c
index 8ecaba2b408..c9a504746b3 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1317,16 +1317,7 @@ relocate_fd (int fd, int minfd)
1317 return fd; 1317 return fd;
1318 else 1318 else
1319 { 1319 {
1320 int new; 1320 int new = fcntl (fd, F_DUPFD, minfd);
1321#ifdef F_DUPFD
1322 new = fcntl (fd, F_DUPFD, minfd);
1323#else
1324 new = dup (fd);
1325 if (new != -1)
1326 /* Note that we hold the original FD open while we recurse,
1327 to guarantee we'll get a new FD if we need it. */
1328 new = relocate_fd (new, minfd);
1329#endif
1330 if (new == -1) 1321 if (new == -1)
1331 { 1322 {
1332 const char *message_1 = "Error while setting up child: "; 1323 const char *message_1 = "Error while setting up child: ";
diff --git a/src/editfns.c b/src/editfns.c
index c5d4ed295ab..8122ffdd0d4 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3434,8 +3434,8 @@ static ptrdiff_t message_length;
3434 3434
3435DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, 3435DEFUN ("message", Fmessage, Smessage, 1, MANY, 0,
3436 doc: /* Display a message at the bottom of the screen. 3436 doc: /* Display a message at the bottom of the screen.
3437The message also goes into the `*Messages*' buffer. 3437The message also goes into the `*Messages*' buffer, if `message-log-max'
3438\(In keyboard macros, that's all it does.) 3438is non-nil. (In keyboard macros, that's all it does.)
3439Return the message. 3439Return the message.
3440 3440
3441The first argument is a format control string, and the rest are data 3441The first argument is a format control string, and the rest are data
diff --git a/src/emacs.c b/src/emacs.c
index fee9c332c55..d69dbfda7bf 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -95,10 +95,6 @@ extern void moncontrol (int mode);
95#include <sys/personality.h> 95#include <sys/personality.h>
96#endif 96#endif
97 97
98#ifndef O_RDWR
99#define O_RDWR 2
100#endif
101
102static const char emacs_version[] = VERSION; 98static const char emacs_version[] = VERSION;
103static const char emacs_copyright[] = COPYRIGHT; 99static const char emacs_copyright[] = COPYRIGHT;
104 100
diff --git a/src/eval.c b/src/eval.c
index dcd48cb7250..f8a76646352 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -508,7 +508,7 @@ spec that specifies non-nil unconditionally (such as \"p\"); or (ii)
508use `called-interactively-p'. */) 508use `called-interactively-p'. */)
509 (void) 509 (void)
510{ 510{
511 return interactive_p () ? Qt : Qnil; 511 return (INTERACTIVE && interactive_p ()) ? Qt : Qnil;
512} 512}
513 513
514 514
@@ -3369,7 +3369,7 @@ mark_backtrace (void)
3369 3369
3370 for (backlist = backtrace_list; backlist; backlist = backlist->next) 3370 for (backlist = backtrace_list; backlist; backlist = backlist->next)
3371 { 3371 {
3372 mark_object (*backlist->function); 3372 mark_object (backlist->function);
3373 3373
3374 if (backlist->nargs == UNEVALLED 3374 if (backlist->nargs == UNEVALLED
3375 || backlist->nargs == MANY) /* FIXME: Can this happen? */ 3375 || backlist->nargs == MANY) /* FIXME: Can this happen? */
diff --git a/src/keyboard.c b/src/keyboard.c
index 8f3a206139d..951d4ad79dc 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -6948,7 +6948,7 @@ tty_read_avail_input (struct terminal *terminal,
6948#elif defined USG || defined CYGWIN 6948#elif defined USG || defined CYGWIN
6949 /* Read some input if available, but don't wait. */ 6949 /* Read some input if available, but don't wait. */
6950 n_to_read = sizeof cbuf; 6950 n_to_read = sizeof cbuf;
6951 fcntl (fileno (tty->input), F_SETFL, O_NDELAY); 6951 fcntl (fileno (tty->input), F_SETFL, O_NONBLOCK);
6952#else 6952#else
6953# error "Cannot read without possibly delaying" 6953# error "Cannot read without possibly delaying"
6954#endif 6954#endif
@@ -6982,7 +6982,7 @@ tty_read_avail_input (struct terminal *terminal,
6982 } 6982 }
6983 while ( 6983 while (
6984 /* We used to retry the read if it was interrupted. 6984 /* We used to retry the read if it was interrupted.
6985 But this does the wrong thing when O_NDELAY causes 6985 But this does the wrong thing when O_NONBLOCK causes
6986 an EAGAIN error. Does anybody know of a situation 6986 an EAGAIN error. Does anybody know of a situation
6987 where a retry is actually needed? */ 6987 where a retry is actually needed? */
6988#if 0 6988#if 0
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index f5cab34d7dc..9778e955677 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -472,6 +472,8 @@ SYSSIGNAL_H = $(SRC)/syssignal.h \
472SYSTTY_H = $(SRC)/systty.h \ 472SYSTTY_H = $(SRC)/systty.h \
473 $(NT_INC)/sys/ioctl.h \ 473 $(NT_INC)/sys/ioctl.h \
474 $(NT_INC)/unistd.h 474 $(NT_INC)/unistd.h
475SYSWAIT_H = $(SRC)/syswait.h \
476 $(NT_INC)/sys/wait.h
475TERMHOOKS_H = $(SRC)/termhooks.h \ 477TERMHOOKS_H = $(SRC)/termhooks.h \
476 $(SYSTIME_H) 478 $(SYSTIME_H)
477W32FONT_H = $(SRC)/w32font.h \ 479W32FONT_H = $(SRC)/w32font.h \
@@ -566,7 +568,6 @@ $(BLD)/callproc.$(O) : \
566 $(SRC)/commands.h \ 568 $(SRC)/commands.h \
567 $(SRC)/composite.h \ 569 $(SRC)/composite.h \
568 $(SRC)/epaths.h \ 570 $(SRC)/epaths.h \
569 $(SRC)/syswait.h \
570 $(SRC)/w32.h \ 571 $(SRC)/w32.h \
571 $(NT_INC)/sys/file.h \ 572 $(NT_INC)/sys/file.h \
572 $(NT_INC)/unistd.h \ 573 $(NT_INC)/unistd.h \
@@ -580,6 +581,7 @@ $(BLD)/callproc.$(O) : \
580 $(PROCESS_H) \ 581 $(PROCESS_H) \
581 $(SYSSIGNAL_H) \ 582 $(SYSSIGNAL_H) \
582 $(SYSTTY_H) \ 583 $(SYSTTY_H) \
584 $(SYSWAIT_H) \
583 $(TERMHOOKS_H) 585 $(TERMHOOKS_H)
584 586
585$(BLD)/casefiddle.$(O) : \ 587$(BLD)/casefiddle.$(O) : \
@@ -737,6 +739,7 @@ $(BLD)/dispnew.$(O) : \
737 $(SRC)/termchar.h \ 739 $(SRC)/termchar.h \
738 $(SRC)/w32.h \ 740 $(SRC)/w32.h \
739 $(NT_INC)/unistd.h \ 741 $(NT_INC)/unistd.h \
742 $(GNU_LIB)/fpending.h \
740 $(BUFFER_H) \ 743 $(BUFFER_H) \
741 $(CHARACTER_H) \ 744 $(CHARACTER_H) \
742 $(CONFIG_H) \ 745 $(CONFIG_H) \
@@ -802,6 +805,7 @@ $(BLD)/emacs.$(O) : \
802 $(SRC)/w32select.h \ 805 $(SRC)/w32select.h \
803 $(NT_INC)/sys/file.h \ 806 $(NT_INC)/sys/file.h \
804 $(NT_INC)/unistd.h \ 807 $(NT_INC)/unistd.h \
808 $(GNU_LIB)/close-stream.h \
805 $(GNU_LIB)/ignore-value.h \ 809 $(GNU_LIB)/ignore-value.h \
806 $(ATIMER_H) \ 810 $(ATIMER_H) \
807 $(BUFFER_H) \ 811 $(BUFFER_H) \
@@ -1214,7 +1218,6 @@ $(BLD)/w32inevt.$(O) : \
1214 1218
1215$(BLD)/w32proc.$(O) : \ 1219$(BLD)/w32proc.$(O) : \
1216 $(SRC)/w32proc.c \ 1220 $(SRC)/w32proc.c \
1217 $(SRC)/syswait.h \
1218 $(SRC)/w32.h \ 1221 $(SRC)/w32.h \
1219 $(SRC)/w32common.h \ 1222 $(SRC)/w32common.h \
1220 $(SRC)/w32heap.h \ 1223 $(SRC)/w32heap.h \
@@ -1228,6 +1231,7 @@ $(BLD)/w32proc.$(O) : \
1228 $(PROCESS_H) \ 1231 $(PROCESS_H) \
1229 $(SYSSIGNAL_H) \ 1232 $(SYSSIGNAL_H) \
1230 $(SYSTIME_H) \ 1233 $(SYSTIME_H) \
1234 $(SYSWAIT_H) \
1231 $(W32TERM_H) 1235 $(W32TERM_H)
1232 1236
1233$(BLD)/w32console.$(O) : \ 1237$(BLD)/w32console.$(O) : \
@@ -1272,7 +1276,6 @@ $(BLD)/process.$(O) : \
1272 $(SRC)/composite.h \ 1276 $(SRC)/composite.h \
1273 $(SRC)/gnutls.h \ 1277 $(SRC)/gnutls.h \
1274 $(SRC)/sysselect.h \ 1278 $(SRC)/sysselect.h \
1275 $(SRC)/syswait.h \
1276 $(SRC)/termopts.h \ 1279 $(SRC)/termopts.h \
1277 $(NT_INC)/arpa/inet.h \ 1280 $(NT_INC)/arpa/inet.h \
1278 $(NT_INC)/netdb.h \ 1281 $(NT_INC)/netdb.h \
@@ -1295,6 +1298,7 @@ $(BLD)/process.$(O) : \
1295 $(SYSSIGNAL_H) \ 1298 $(SYSSIGNAL_H) \
1296 $(SYSTIME_H) \ 1299 $(SYSTIME_H) \
1297 $(SYSTTY_H) \ 1300 $(SYSTTY_H) \
1301 $(SYSWAIT_H) \
1298 $(TERMHOOKS_H) \ 1302 $(TERMHOOKS_H) \
1299 $(W32TERM_H) \ 1303 $(W32TERM_H) \
1300 $(WINDOW_H) 1304 $(WINDOW_H)
@@ -1378,7 +1382,6 @@ $(BLD)/sysdep.$(O) : \
1378 $(SRC)/blockinput.h \ 1382 $(SRC)/blockinput.h \
1379 $(SRC)/cm.h \ 1383 $(SRC)/cm.h \
1380 $(SRC)/sysselect.h \ 1384 $(SRC)/sysselect.h \
1381 $(SRC)/syswait.h \
1382 $(SRC)/termchar.h \ 1385 $(SRC)/termchar.h \
1383 $(SRC)/termopts.h \ 1386 $(SRC)/termopts.h \
1384 $(NT_INC)/netdb.h \ 1387 $(NT_INC)/netdb.h \
@@ -1403,6 +1406,7 @@ $(BLD)/sysdep.$(O) : \
1403 $(SYSSIGNAL_H) \ 1406 $(SYSSIGNAL_H) \
1404 $(SYSTIME_H) \ 1407 $(SYSTIME_H) \
1405 $(SYSTTY_H) \ 1408 $(SYSTTY_H) \
1409 $(SYSWAIT_H) \
1406 $(TERMHOOKS_H) \ 1410 $(TERMHOOKS_H) \
1407 $(WINDOW_H) 1411 $(WINDOW_H)
1408 1412
diff --git a/src/nsterm.m b/src/nsterm.m
index 804ab825dee..57d32ee0528 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -30,7 +30,9 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
30 interpretation of even the system includes. */ 30 interpretation of even the system includes. */
31#include <config.h> 31#include <config.h>
32 32
33#include <fcntl.h>
33#include <math.h> 34#include <math.h>
35#include <pthread.h>
34#include <sys/types.h> 36#include <sys/types.h>
35#include <time.h> 37#include <time.h>
36#include <signal.h> 38#include <signal.h>
@@ -40,10 +42,6 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
40#include <c-strcase.h> 42#include <c-strcase.h>
41#include <ftoastr.h> 43#include <ftoastr.h>
42 44
43#ifdef HAVE_FCNTL_H
44#include <fcntl.h>
45#endif
46
47#include "lisp.h" 45#include "lisp.h"
48#include "blockinput.h" 46#include "blockinput.h"
49#include "sysselect.h" 47#include "sysselect.h"
@@ -330,6 +328,9 @@ hold_event (struct input_event *event)
330 } 328 }
331 329
332 hold_event_q.q[hold_event_q.nr++] = *event; 330 hold_event_q.q[hold_event_q.nr++] = *event;
331 /* Make sure ns_read_socket is called, i.e. we have input. */
332 raise (SIGIO);
333 send_appdefined = YES;
333} 334}
334 335
335static Lisp_Object 336static Lisp_Object
@@ -3387,7 +3388,7 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
3387 if ([NSApp modalWindow] != nil) 3388 if ([NSApp modalWindow] != nil)
3388 return -1; 3389 return -1;
3389 3390
3390 if (hold_event_q.nr > 0) 3391 if (hold_event_q.nr > 0)
3391 { 3392 {
3392 int i; 3393 int i;
3393 for (i = 0; i < hold_event_q.nr; ++i) 3394 for (i = 0; i < hold_event_q.nr; ++i)
@@ -3461,6 +3462,14 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3461 3462
3462/* NSTRACE (ns_select); */ 3463/* NSTRACE (ns_select); */
3463 3464
3465 if (hold_event_q.nr > 0)
3466 {
3467 /* We already have events pending. */
3468 raise (SIGIO);
3469 errno = EINTR;
3470 return -1;
3471 }
3472
3464 for (k = 0; k < nfds+1; k++) 3473 for (k = 0; k < nfds+1; k++)
3465 { 3474 {
3466 if (readfds && FD_ISSET(k, readfds)) ++nr; 3475 if (readfds && FD_ISSET(k, readfds)) ++nr;
@@ -3502,7 +3511,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3502 3511
3503 /* Inform fd_handler that select should be called */ 3512 /* Inform fd_handler that select should be called */
3504 c = 'g'; 3513 c = 'g';
3505 write (selfds[1], &c, 1); 3514 emacs_write (selfds[1], &c, 1);
3506 } 3515 }
3507 else if (nr == 0 && timeout) 3516 else if (nr == 0 && timeout)
3508 { 3517 {
@@ -3535,7 +3544,7 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
3535 if (nr > 0 && readfds) 3544 if (nr > 0 && readfds)
3536 { 3545 {
3537 c = 's'; 3546 c = 's';
3538 write (selfds[1], &c, 1); 3547 emacs_write (selfds[1], &c, 1);
3539 } 3548 }
3540 unblock_input (); 3549 unblock_input ();
3541 3550
@@ -4574,11 +4583,8 @@ not_in_argv (NSString *arg)
4574 4583
4575 FD_SET (selfds[0], &fds); 4584 FD_SET (selfds[0], &fds);
4576 result = select (selfds[0]+1, &fds, NULL, NULL, NULL); 4585 result = select (selfds[0]+1, &fds, NULL, NULL, NULL);
4577 if (result > 0) 4586 if (result > 0 && read (selfds[0], &c, 1) == 1 && c == 'g')
4578 { 4587 waiting = 0;
4579 read (selfds[0], &c, 1);
4580 if (c == 'g') waiting = 0;
4581 }
4582 } 4588 }
4583 else 4589 else
4584 { 4590 {
@@ -4618,8 +4624,8 @@ not_in_argv (NSString *arg)
4618 { 4624 {
4619 if (FD_ISSET (selfds[0], &readfds)) 4625 if (FD_ISSET (selfds[0], &readfds))
4620 { 4626 {
4621 read (selfds[0], &c, 1); 4627 if (read (selfds[0], &c, 1) == 1 && c == 's')
4622 if (c == 's') waiting = 1; 4628 waiting = 1;
4623 } 4629 }
4624 else 4630 else
4625 { 4631 {
@@ -6694,7 +6700,7 @@ not_in_argv (NSString *arg)
6694 /* Events may come here even if the event loop is not running. 6700 /* Events may come here even if the event loop is not running.
6695 If we don't enter the event loop, the scroll bar will not update. 6701 If we don't enter the event loop, the scroll bar will not update.
6696 So send SIGIO to ourselves. */ 6702 So send SIGIO to ourselves. */
6697 if (apploopnr == 0) kill (0, SIGIO); 6703 if (apploopnr == 0) raise (SIGIO);
6698 6704
6699 return self; 6705 return self;
6700} 6706}
diff --git a/src/process.c b/src/process.c
index 728abebe758..0036ce595f5 100644
--- a/src/process.c
+++ b/src/process.c
@@ -130,18 +130,6 @@ extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
130 EMACS_TIME *, void *); 130 EMACS_TIME *, void *);
131#endif 131#endif
132 132
133/* This is for DOS_NT ports. FIXME: Remove this old portability cruft
134 by having DOS_NT ports implement waitpid instead of wait. Nowadays
135 POSIXish hosts all define waitpid, WNOHANG, and WUNTRACED, as these
136 have been standard since POSIX.1-1988. */
137#ifndef WNOHANG
138# undef waitpid
139# define waitpid(pid, status, options) wait (status)
140#endif
141#ifndef WUNTRACED
142# define WUNTRACED 0
143#endif
144
145/* Work around GCC 4.7.0 bug with strict overflow checking; see 133/* Work around GCC 4.7.0 bug with strict overflow checking; see
146 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 134 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
147 These lines can be removed once the GCC bug is fixed. */ 135 These lines can be removed once the GCC bug is fixed. */
@@ -208,11 +196,9 @@ static EMACS_INT update_tick;
208#ifndef NON_BLOCKING_CONNECT 196#ifndef NON_BLOCKING_CONNECT
209#ifdef HAVE_SELECT 197#ifdef HAVE_SELECT
210#if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) 198#if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX)
211#if O_NONBLOCK || O_NDELAY
212#if defined (EWOULDBLOCK) || defined (EINPROGRESS) 199#if defined (EWOULDBLOCK) || defined (EINPROGRESS)
213#define NON_BLOCKING_CONNECT 200#define NON_BLOCKING_CONNECT
214#endif /* EWOULDBLOCK || EINPROGRESS */ 201#endif /* EWOULDBLOCK || EINPROGRESS */
215#endif /* O_NONBLOCK || O_NDELAY */
216#endif /* HAVE_GETPEERNAME || GNU_LINUX */ 202#endif /* HAVE_GETPEERNAME || GNU_LINUX */
217#endif /* HAVE_SELECT */ 203#endif /* HAVE_SELECT */
218#endif /* NON_BLOCKING_CONNECT */ 204#endif /* NON_BLOCKING_CONNECT */
@@ -340,9 +326,6 @@ static struct sockaddr_and_len {
340#define DATAGRAM_CONN_P(proc) (0) 326#define DATAGRAM_CONN_P(proc) (0)
341#endif 327#endif
342 328
343/* Maximum number of bytes to send to a pty without an eof. */
344static int pty_max_bytes;
345
346/* These setters are used only in this file, so they can be private. */ 329/* These setters are used only in this file, so they can be private. */
347static void 330static void
348pset_buffer (struct Lisp_Process *p, Lisp_Object val) 331pset_buffer (struct Lisp_Process *p, Lisp_Object val)
@@ -654,13 +637,7 @@ allocate_pty (void)
654#ifdef PTY_OPEN 637#ifdef PTY_OPEN
655 PTY_OPEN; 638 PTY_OPEN;
656#else /* no PTY_OPEN */ 639#else /* no PTY_OPEN */
657 { 640 fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0);
658# if O_NONBLOCK
659 fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0);
660# else
661 fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0);
662# endif
663 }
664#endif /* no PTY_OPEN */ 641#endif /* no PTY_OPEN */
665 642
666 if (fd >= 0) 643 if (fd >= 0)
@@ -1598,7 +1575,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1598 int inchannel, outchannel; 1575 int inchannel, outchannel;
1599 pid_t pid; 1576 pid_t pid;
1600 int sv[2]; 1577 int sv[2];
1601#if !defined (WINDOWSNT) && defined (FD_CLOEXEC) 1578#ifndef WINDOWSNT
1602 int wait_child_setup[2]; 1579 int wait_child_setup[2];
1603#endif 1580#endif
1604#ifdef SIGCHLD 1581#ifdef SIGCHLD
@@ -1624,13 +1601,9 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1624#if ! defined (USG) || defined (USG_SUBTTY_WORKS) 1601#if ! defined (USG) || defined (USG_SUBTTY_WORKS)
1625 /* On most USG systems it does not work to open the pty's tty here, 1602 /* On most USG systems it does not work to open the pty's tty here,
1626 then close it and reopen it in the child. */ 1603 then close it and reopen it in the child. */
1627#if O_NOCTTY
1628 /* Don't let this terminal become our controlling terminal 1604 /* Don't let this terminal become our controlling terminal
1629 (in case we don't have one). */ 1605 (in case we don't have one). */
1630 forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); 1606 forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0);
1631#else
1632 forkout = forkin = emacs_open (pty_name, O_RDWR, 0);
1633#endif
1634 if (forkin < 0) 1607 if (forkin < 0)
1635 report_file_error ("Opening pty", Qnil); 1608 report_file_error ("Opening pty", Qnil);
1636#else 1609#else
@@ -1659,7 +1632,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1659 forkin = sv[0]; 1632 forkin = sv[0];
1660 } 1633 }
1661 1634
1662#if !defined (WINDOWSNT) && defined (FD_CLOEXEC) 1635#ifndef WINDOWSNT
1663 { 1636 {
1664 int tem; 1637 int tem;
1665 1638
@@ -1678,15 +1651,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1678 } 1651 }
1679#endif 1652#endif
1680 1653
1681#if O_NONBLOCK
1682 fcntl (inchannel, F_SETFL, O_NONBLOCK); 1654 fcntl (inchannel, F_SETFL, O_NONBLOCK);
1683 fcntl (outchannel, F_SETFL, O_NONBLOCK); 1655 fcntl (outchannel, F_SETFL, O_NONBLOCK);
1684#else
1685#if O_NDELAY
1686 fcntl (inchannel, F_SETFL, O_NDELAY);
1687 fcntl (outchannel, F_SETFL, O_NDELAY);
1688#endif
1689#endif
1690 1656
1691 /* Record this as an active process, with its channels. 1657 /* Record this as an active process, with its channels.
1692 As a result, child_setup will close Emacs's side of the pipes. */ 1658 As a result, child_setup will close Emacs's side of the pipes. */
@@ -1845,9 +1811,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1845 pid = child_setup (xforkin, xforkout, xforkout, 1811 pid = child_setup (xforkin, xforkout, xforkout,
1846 new_argv, 1, encoded_current_dir); 1812 new_argv, 1, encoded_current_dir);
1847#else /* not WINDOWSNT */ 1813#else /* not WINDOWSNT */
1848#ifdef FD_CLOEXEC
1849 emacs_close (wait_child_setup[0]); 1814 emacs_close (wait_child_setup[0]);
1850#endif
1851 child_setup (xforkin, xforkout, xforkout, 1815 child_setup (xforkin, xforkout, xforkout,
1852 new_argv, 1, encoded_current_dir); 1816 new_argv, 1, encoded_current_dir);
1853#endif /* not WINDOWSNT */ 1817#endif /* not WINDOWSNT */
@@ -1906,7 +1870,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1906 1870
1907 pset_tty_name (XPROCESS (process), lisp_pty_name); 1871 pset_tty_name (XPROCESS (process), lisp_pty_name);
1908 1872
1909#if !defined (WINDOWSNT) && defined (FD_CLOEXEC) 1873#ifndef WINDOWSNT
1910 /* Wait for child_setup to complete in case that vfork is 1874 /* Wait for child_setup to complete in case that vfork is
1911 actually defined as fork. The descriptor wait_child_setup[1] 1875 actually defined as fork. The descriptor wait_child_setup[1]
1912 of a pipe is closed at the child side either by close-on-exec 1876 of a pipe is closed at the child side either by close-on-exec
@@ -1943,13 +1907,9 @@ create_pty (Lisp_Object process)
1943#if ! defined (USG) || defined (USG_SUBTTY_WORKS) 1907#if ! defined (USG) || defined (USG_SUBTTY_WORKS)
1944 /* On most USG systems it does not work to open the pty's tty here, 1908 /* On most USG systems it does not work to open the pty's tty here,
1945 then close it and reopen it in the child. */ 1909 then close it and reopen it in the child. */
1946#if O_NOCTTY
1947 /* Don't let this terminal become our controlling terminal 1910 /* Don't let this terminal become our controlling terminal
1948 (in case we don't have one). */ 1911 (in case we don't have one). */
1949 int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); 1912 int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0);
1950#else
1951 int forkout = emacs_open (pty_name, O_RDWR, 0);
1952#endif
1953 if (forkout < 0) 1913 if (forkout < 0)
1954 report_file_error ("Opening pty", Qnil); 1914 report_file_error ("Opening pty", Qnil);
1955#if defined (DONT_REOPEN_PTY) 1915#if defined (DONT_REOPEN_PTY)
@@ -1963,15 +1923,8 @@ create_pty (Lisp_Object process)
1963 } 1923 }
1964#endif /* HAVE_PTYS */ 1924#endif /* HAVE_PTYS */
1965 1925
1966#if O_NONBLOCK
1967 fcntl (inchannel, F_SETFL, O_NONBLOCK); 1926 fcntl (inchannel, F_SETFL, O_NONBLOCK);
1968 fcntl (outchannel, F_SETFL, O_NONBLOCK); 1927 fcntl (outchannel, F_SETFL, O_NONBLOCK);
1969#else
1970#if O_NDELAY
1971 fcntl (inchannel, F_SETFL, O_NDELAY);
1972 fcntl (outchannel, F_SETFL, O_NDELAY);
1973#endif
1974#endif
1975 1928
1976 /* Record this as an active process, with its channels. 1929 /* Record this as an active process, with its channels.
1977 As a result, child_setup will close Emacs's side of the pipes. */ 1930 As a result, child_setup will close Emacs's side of the pipes. */
@@ -2927,13 +2880,9 @@ usage: (make-network-process &rest ARGS) */)
2927 { 2880 {
2928 /* Don't support network sockets when non-blocking mode is 2881 /* Don't support network sockets when non-blocking mode is
2929 not available, since a blocked Emacs is not useful. */ 2882 not available, since a blocked Emacs is not useful. */
2930#if !O_NONBLOCK && !O_NDELAY
2931 error ("Network servers not supported");
2932#else
2933 is_server = 1; 2883 is_server = 1;
2934 if (TYPE_RANGED_INTEGERP (int, tem)) 2884 if (TYPE_RANGED_INTEGERP (int, tem))
2935 backlog = XINT (tem); 2885 backlog = XINT (tem);
2936#endif
2937 } 2886 }
2938 2887
2939 /* Make QCaddress an alias for :local (server) or :remote (client). */ 2888 /* Make QCaddress an alias for :local (server) or :remote (client). */
@@ -3193,11 +3142,7 @@ usage: (make-network-process &rest ARGS) */)
3193#ifdef NON_BLOCKING_CONNECT 3142#ifdef NON_BLOCKING_CONNECT
3194 if (is_non_blocking_client) 3143 if (is_non_blocking_client)
3195 { 3144 {
3196#if O_NONBLOCK
3197 ret = fcntl (s, F_SETFL, O_NONBLOCK); 3145 ret = fcntl (s, F_SETFL, O_NONBLOCK);
3198#else
3199 ret = fcntl (s, F_SETFL, O_NDELAY);
3200#endif
3201 if (ret < 0) 3146 if (ret < 0)
3202 { 3147 {
3203 xerrno = errno; 3148 xerrno = errno;
@@ -3410,13 +3355,7 @@ usage: (make-network-process &rest ARGS) */)
3410 3355
3411 chan_process[inch] = proc; 3356 chan_process[inch] = proc;
3412 3357
3413#if O_NONBLOCK
3414 fcntl (inch, F_SETFL, O_NONBLOCK); 3358 fcntl (inch, F_SETFL, O_NONBLOCK);
3415#else
3416#if O_NDELAY
3417 fcntl (inch, F_SETFL, O_NDELAY);
3418#endif
3419#endif
3420 3359
3421 p = XPROCESS (proc); 3360 p = XPROCESS (proc);
3422 3361
@@ -4145,13 +4084,7 @@ server_accept_connection (Lisp_Object server, int channel)
4145 4084
4146 chan_process[s] = proc; 4085 chan_process[s] = proc;
4147 4086
4148#if O_NONBLOCK
4149 fcntl (s, F_SETFL, O_NONBLOCK); 4087 fcntl (s, F_SETFL, O_NONBLOCK);
4150#else
4151#if O_NDELAY
4152 fcntl (s, F_SETFL, O_NDELAY);
4153#endif
4154#endif
4155 4088
4156 p = XPROCESS (proc); 4089 p = XPROCESS (proc);
4157 4090
@@ -4847,23 +4780,17 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4847 else if (nread == -1 && errno == EWOULDBLOCK) 4780 else if (nread == -1 && errno == EWOULDBLOCK)
4848 ; 4781 ;
4849#endif 4782#endif
4850 /* ISC 4.1 defines both EWOULDBLOCK and O_NONBLOCK,
4851 and Emacs uses O_NONBLOCK, so what we get is EAGAIN. */
4852#if O_NONBLOCK
4853 else if (nread == -1 && errno == EAGAIN)
4854 ;
4855#else
4856#if O_NDELAY
4857 else if (nread == -1 && errno == EAGAIN) 4783 else if (nread == -1 && errno == EAGAIN)
4858 ; 4784 ;
4785#ifdef WINDOWSNT
4786 /* FIXME: Is this special case still needed? */
4859 /* Note that we cannot distinguish between no input 4787 /* Note that we cannot distinguish between no input
4860 available now and a closed pipe. 4788 available now and a closed pipe.
4861 With luck, a closed pipe will be accompanied by 4789 With luck, a closed pipe will be accompanied by
4862 subprocess termination and SIGCHLD. */ 4790 subprocess termination and SIGCHLD. */
4863 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) 4791 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc))
4864 ; 4792 ;
4865#endif /* O_NDELAY */ 4793#endif
4866#endif /* O_NONBLOCK */
4867#ifdef HAVE_PTYS 4794#ifdef HAVE_PTYS
4868 /* On some OSs with ptys, when the process on one end of 4795 /* On some OSs with ptys, when the process on one end of
4869 a pty exits, the other end gets an error reading with 4796 a pty exits, the other end gets an error reading with
@@ -5532,19 +5459,6 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5532 buf = SSDATA (object); 5459 buf = SSDATA (object);
5533 } 5460 }
5534 5461
5535 if (pty_max_bytes == 0)
5536 {
5537#if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON)
5538 pty_max_bytes = fpathconf (p->outfd, _PC_MAX_CANON);
5539 if (pty_max_bytes < 0)
5540 pty_max_bytes = 250;
5541#else
5542 pty_max_bytes = 250;
5543#endif
5544 /* Deduct one, to leave space for the eof. */
5545 pty_max_bytes--;
5546 }
5547
5548 /* If there is already data in the write_queue, put the new data 5462 /* If there is already data in the write_queue, put the new data
5549 in the back of queue. Otherwise, ignore it. */ 5463 in the back of queue. Otherwise, ignore it. */
5550 if (!NILP (p->write_queue)) 5464 if (!NILP (p->write_queue))
@@ -6311,17 +6225,9 @@ record_child_status_change (pid_t pid, int w)
6311{ 6225{
6312#ifdef SIGCHLD 6226#ifdef SIGCHLD
6313 6227
6314# ifdef WNOHANG 6228 /* Record at most one child only if we already know one child that
6315 /* On POSIXish hosts, record at most one child only if we already 6229 has exited. */
6316 know one child that has exited. */
6317 bool record_at_most_one_child = 0 <= pid; 6230 bool record_at_most_one_child = 0 <= pid;
6318# else
6319 /* On DOS_NT (the only porting target that lacks WNOHANG),
6320 record the status of at most one child process, since the SIGCHLD
6321 handler must return right away. If any more processes want to
6322 signal us, we will get another signal. */
6323 bool record_at_most_one_child = 1;
6324# endif
6325 6231
6326 Lisp_Object tail; 6232 Lisp_Object tail;
6327 6233
@@ -7348,9 +7254,7 @@ init_process_emacs (void)
7348#ifdef HAVE_GETSOCKNAME 7254#ifdef HAVE_GETSOCKNAME
7349 ADD_SUBFEATURE (QCservice, Qt); 7255 ADD_SUBFEATURE (QCservice, Qt);
7350#endif 7256#endif
7351#if O_NONBLOCK || O_NDELAY
7352 ADD_SUBFEATURE (QCserver, Qt); 7257 ADD_SUBFEATURE (QCserver, Qt);
7353#endif
7354 7258
7355 for (sopt = socket_options; sopt->name; sopt++) 7259 for (sopt = socket_options; sopt->name; sopt++)
7356 subfeatures = pure_cons (intern_c_string (sopt->name), subfeatures); 7260 subfeatures = pure_cons (intern_c_string (sopt->name), subfeatures);
diff --git a/src/sysdep.c b/src/sysdep.c
index a7f3de2f1b1..7c5c144fa8c 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -289,10 +289,6 @@ wait_for_termination_1 (pid_t pid, int interruptible)
289{ 289{
290 while (1) 290 while (1)
291 { 291 {
292#ifdef WINDOWSNT
293 wait (0);
294 break;
295#else /* not WINDOWSNT */
296 int status; 292 int status;
297 int wait_result = waitpid (pid, &status, 0); 293 int wait_result = waitpid (pid, &status, 0);
298 if (wait_result < 0) 294 if (wait_result < 0)
@@ -306,7 +302,8 @@ wait_for_termination_1 (pid_t pid, int interruptible)
306 break; 302 break;
307 } 303 }
308 304
309#endif /* not WINDOWSNT */ 305 /* Note: the MS-Windows emulation of waitpid calls QUIT
306 internally. */
310 if (interruptible) 307 if (interruptible)
311 QUIT; 308 QUIT;
312 } 309 }
@@ -1039,8 +1036,7 @@ init_sys_modes (struct tty_display_info *tty_out)
1039#endif 1036#endif
1040#endif 1037#endif
1041 1038
1042#ifdef F_SETFL 1039#ifdef F_GETOWN
1043#ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */
1044 if (interrupt_input) 1040 if (interrupt_input)
1045 { 1041 {
1046 old_fcntl_owner[fileno (tty_out->input)] = 1042 old_fcntl_owner[fileno (tty_out->input)] =
@@ -1058,7 +1054,6 @@ init_sys_modes (struct tty_display_info *tty_out)
1058#endif /* HAVE_GPM */ 1054#endif /* HAVE_GPM */
1059 } 1055 }
1060#endif /* F_GETOWN */ 1056#endif /* F_GETOWN */
1061#endif /* F_SETFL */
1062 1057
1063#ifdef _IOFBF 1058#ifdef _IOFBF
1064 /* This symbol is defined on recent USG systems. 1059 /* This symbol is defined on recent USG systems.
@@ -1278,8 +1273,8 @@ reset_sys_modes (struct tty_display_info *tty_out)
1278 fsync (fileno (tty_out->output)); 1273 fsync (fileno (tty_out->output));
1279#endif 1274#endif
1280 1275
1281#ifdef F_SETFL 1276#ifndef DOS_NT
1282#ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ 1277#ifdef F_SETOWN
1283 if (interrupt_input) 1278 if (interrupt_input)
1284 { 1279 {
1285 reset_sigio (fileno (tty_out->input)); 1280 reset_sigio (fileno (tty_out->input));
@@ -1287,11 +1282,9 @@ reset_sys_modes (struct tty_display_info *tty_out)
1287 old_fcntl_owner[fileno (tty_out->input)]); 1282 old_fcntl_owner[fileno (tty_out->input)]);
1288 } 1283 }
1289#endif /* F_SETOWN */ 1284#endif /* F_SETOWN */
1290#if O_NDELAY
1291 fcntl (fileno (tty_out->input), F_SETFL, 1285 fcntl (fileno (tty_out->input), F_SETFL,
1292 fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NDELAY); 1286 fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NONBLOCK);
1293#endif 1287#endif
1294#endif /* F_SETFL */
1295 1288
1296 if (tty_out->old_tty) 1289 if (tty_out->old_tty)
1297 while (emacs_set_tty (fileno (tty_out->input), 1290 while (emacs_set_tty (fileno (tty_out->input),
@@ -2380,19 +2373,7 @@ safe_strsignal (int code)
2380int 2373int
2381serial_open (char *port) 2374serial_open (char *port)
2382{ 2375{
2383 int fd = -1; 2376 int fd = emacs_open (port, O_RDWR | O_NOCTTY | O_NONBLOCK, 0);
2384
2385 fd = emacs_open ((char*) port,
2386 O_RDWR
2387#if O_NONBLOCK
2388 | O_NONBLOCK
2389#else
2390 | O_NDELAY
2391#endif
2392#if O_NOCTTY
2393 | O_NOCTTY
2394#endif
2395 , 0);
2396 if (fd < 0) 2377 if (fd < 0)
2397 { 2378 {
2398 error ("Could not open %s: %s", 2379 error ("Could not open %s: %s",
diff --git a/src/term.c b/src/term.c
index 96549290da5..481a3423989 100644
--- a/src/term.c
+++ b/src/term.c
@@ -20,8 +20,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20/* New redisplay, TTY faces by Gerd Moellmann <gerd@gnu.org>. */ 20/* New redisplay, TTY faces by Gerd Moellmann <gerd@gnu.org>. */
21 21
22#include <config.h> 22#include <config.h>
23#include <stdio.h>
24#include <errno.h> 23#include <errno.h>
24#include <fcntl.h>
25#include <stdio.h>
25#include <sys/file.h> 26#include <sys/file.h>
26#include <sys/time.h> 27#include <sys/time.h>
27#include <unistd.h> 28#include <unistd.h>
@@ -55,14 +56,6 @@ static int been_here = -1;
55#include "xterm.h" 56#include "xterm.h"
56#endif 57#endif
57 58
58#ifndef O_RDWR
59#define O_RDWR 2
60#endif
61
62#ifndef O_NOCTTY
63#define O_NOCTTY 0
64#endif
65
66/* The name of the default console device. */ 59/* The name of the default console device. */
67#ifdef WINDOWSNT 60#ifdef WINDOWSNT
68#define DEV_TTY "CONOUT$" 61#define DEV_TTY "CONOUT$"
@@ -2989,22 +2982,18 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
2989 set_tty_hooks (terminal); 2982 set_tty_hooks (terminal);
2990 2983
2991 { 2984 {
2992 int fd; 2985 /* Open the terminal device. */
2993 FILE *file; 2986 FILE *file;
2994 2987
2995#if O_IGNORE_CTTY 2988 /* If !ctty, don't recognize it as our controlling terminal, and
2996 if (!ctty) 2989 don't make it the controlling tty if we don't have one now.
2997 /* Open the terminal device. Don't recognize it as our 2990
2998 controlling terminal, and don't make it the controlling tty 2991 Alas, O_IGNORE_CTTY is a GNU extension that seems to be only
2999 if we don't have one at the moment. */ 2992 defined on Hurd. On other systems, we need to explicitly
3000 fd = emacs_open (name, O_RDWR | O_IGNORE_CTTY | O_NOCTTY, 0); 2993 dissociate ourselves from the controlling tty when we want to
3001 else 2994 open a frame on the same terminal. */
3002#endif /* O_IGNORE_CTTY */ 2995 int flags = O_RDWR | O_NOCTTY | (ctty ? 0 : O_IGNORE_CTTY);
3003 /* Alas, O_IGNORE_CTTY is a GNU extension that seems to be only 2996 int fd = emacs_open (name, flags, 0);
3004 defined on Hurd. On other systems, we need to explicitly
3005 dissociate ourselves from the controlling tty when we want to
3006 open a frame on the same terminal. */
3007 fd = emacs_open (name, O_RDWR | O_NOCTTY, 0);
3008 2997
3009 tty->name = xstrdup (name); 2998 tty->name = xstrdup (name);
3010 terminal->name = xstrdup (name); 2999 terminal->name = xstrdup (name);
@@ -3023,10 +3012,8 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3023 name); 3012 name);
3024 } 3013 }
3025 3014
3026#if !O_IGNORE_CTTY 3015 if (!O_IGNORE_CTTY && !ctty)
3027 if (!ctty)
3028 dissociate_if_controlling_tty (fd); 3016 dissociate_if_controlling_tty (fd);
3029#endif
3030 3017
3031 file = fdopen (fd, "w+"); 3018 file = fdopen (fd, "w+");
3032 tty->input = file; 3019 tty->input = file;
diff --git a/src/unexelf.c b/src/unexelf.c
index 121e6042fc9..b9f8e05e959 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -461,7 +461,7 @@ typedef struct {
461/* 461/*
462 * NetBSD does not have normal-looking user-land ELF support. 462 * NetBSD does not have normal-looking user-land ELF support.
463 */ 463 */
464# if defined __alpha__ || defined __sparc_v9__ 464# if defined __alpha__ || defined __sparc_v9__ || defined _LP64
465# define ELFSIZE 64 465# define ELFSIZE 64
466# else 466# else
467# define ELFSIZE 32 467# define ELFSIZE 32
diff --git a/src/w32.c b/src/w32.c
index 0e7da449b81..94cf472a4ae 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1597,7 +1597,7 @@ init_environment (char ** argv)
1597 see if it succeeds. But I think that's too much to ask. */ 1597 see if it succeeds. But I think that's too much to ask. */
1598 1598
1599 /* MSVCRT's _access crashes with D_OK. */ 1599 /* MSVCRT's _access crashes with D_OK. */
1600 if (tmp && sys_faccessat (AT_FDCWD, tmp, D_OK, AT_EACCESS) == 0) 1600 if (tmp && faccessat (AT_FDCWD, tmp, D_OK, AT_EACCESS) == 0)
1601 { 1601 {
1602 char * var = alloca (strlen (tmp) + 8); 1602 char * var = alloca (strlen (tmp) + 8);
1603 sprintf (var, "TMPDIR=%s", tmp); 1603 sprintf (var, "TMPDIR=%s", tmp);
@@ -2708,17 +2708,15 @@ logon_network_drive (const char *path)
2708 WNetAddConnection2 (&resource, NULL, NULL, CONNECT_INTERACTIVE); 2708 WNetAddConnection2 (&resource, NULL, NULL, CONNECT_INTERACTIVE);
2709} 2709}
2710 2710
2711/* Shadow some MSVC runtime functions to map requests for long filenames 2711/* Emulate faccessat(2). */
2712 to reasonable short names if necessary. This was originally added to
2713 permit running Emacs on NT 3.1 on a FAT partition, which doesn't support
2714 long file names. */
2715
2716int 2712int
2717sys_faccessat (int dirfd, const char * path, int mode, int flags) 2713faccessat (int dirfd, const char * path, int mode, int flags)
2718{ 2714{
2719 DWORD attributes; 2715 DWORD attributes;
2720 2716
2721 if (dirfd != AT_FDCWD) 2717 if (dirfd != AT_FDCWD
2718 && !(IS_DIRECTORY_SEP (path[0])
2719 || IS_DEVICE_SEP (path[1])))
2722 { 2720 {
2723 errno = EBADF; 2721 errno = EBADF;
2724 return -1; 2722 return -1;
@@ -2731,7 +2729,8 @@ sys_faccessat (int dirfd, const char * path, int mode, int flags)
2731 to get the attributes of its target file. Note: any symlinks in 2729 to get the attributes of its target file. Note: any symlinks in
2732 PATH elements other than the last one are transparently resolved 2730 PATH elements other than the last one are transparently resolved
2733 by GetFileAttributes below. */ 2731 by GetFileAttributes below. */
2734 if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0) 2732 if ((volume_info.flags & FILE_SUPPORTS_REPARSE_POINTS) != 0
2733 && (flags & AT_SYMLINK_NOFOLLOW) == 0)
2735 path = chase_symlinks (path); 2734 path = chase_symlinks (path);
2736 2735
2737 if ((attributes = GetFileAttributes (path)) == -1) 2736 if ((attributes = GetFileAttributes (path)) == -1)
@@ -2763,7 +2762,8 @@ sys_faccessat (int dirfd, const char * path, int mode, int flags)
2763 } 2762 }
2764 return -1; 2763 return -1;
2765 } 2764 }
2766 if ((mode & X_OK) != 0 && !is_exec (path)) 2765 if ((mode & X_OK) != 0
2766 && !(is_exec (path) || (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0))
2767 { 2767 {
2768 errno = EACCES; 2768 errno = EACCES;
2769 return -1; 2769 return -1;
@@ -2781,6 +2781,11 @@ sys_faccessat (int dirfd, const char * path, int mode, int flags)
2781 return 0; 2781 return 0;
2782} 2782}
2783 2783
2784/* Shadow some MSVC runtime functions to map requests for long filenames
2785 to reasonable short names if necessary. This was originally added to
2786 permit running Emacs on NT 3.1 on a FAT partition, which doesn't support
2787 long file names. */
2788
2784int 2789int
2785sys_chdir (const char * path) 2790sys_chdir (const char * path)
2786{ 2791{
@@ -2966,7 +2971,7 @@ sys_mktemp (char * template)
2966 { 2971 {
2967 int save_errno = errno; 2972 int save_errno = errno;
2968 p[0] = first_char[i]; 2973 p[0] = first_char[i];
2969 if (sys_faccessat (AT_FDCWD, template, F_OK, AT_EACCESS) < 0) 2974 if (faccessat (AT_FDCWD, template, F_OK, AT_EACCESS) < 0)
2970 { 2975 {
2971 errno = save_errno; 2976 errno = save_errno;
2972 return template; 2977 return template;
@@ -4017,7 +4022,7 @@ symlink (char const *filename, char const *linkname)
4017 { 4022 {
4018 /* Non-absolute FILENAME is understood as being relative to 4023 /* Non-absolute FILENAME is understood as being relative to
4019 LINKNAME's directory. We need to prepend that directory to 4024 LINKNAME's directory. We need to prepend that directory to
4020 FILENAME to get correct results from sys_faccessat below, since 4025 FILENAME to get correct results from faccessat below, since
4021 otherwise it will interpret FILENAME relative to the 4026 otherwise it will interpret FILENAME relative to the
4022 directory where the Emacs process runs. Note that 4027 directory where the Emacs process runs. Note that
4023 make-symbolic-link always makes sure LINKNAME is a fully 4028 make-symbolic-link always makes sure LINKNAME is a fully
@@ -4031,10 +4036,10 @@ symlink (char const *filename, char const *linkname)
4031 strncpy (tem, linkfn, p - linkfn); 4036 strncpy (tem, linkfn, p - linkfn);
4032 tem[p - linkfn] = '\0'; 4037 tem[p - linkfn] = '\0';
4033 strcat (tem, filename); 4038 strcat (tem, filename);
4034 dir_access = sys_faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS); 4039 dir_access = faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS);
4035 } 4040 }
4036 else 4041 else
4037 dir_access = sys_faccessat (AT_FDCWD, filename, D_OK, AT_EACCESS); 4042 dir_access = faccessat (AT_FDCWD, filename, D_OK, AT_EACCESS);
4038 4043
4039 /* Since Windows distinguishes between symlinks to directories and 4044 /* Since Windows distinguishes between symlinks to directories and
4040 to files, we provide a kludgy feature: if FILENAME doesn't 4045 to files, we provide a kludgy feature: if FILENAME doesn't
@@ -5849,7 +5854,7 @@ fcntl (int s, int cmd, int options)
5849 check_errno (); 5854 check_errno ();
5850 if (fd_info[s].flags & FILE_SOCKET) 5855 if (fd_info[s].flags & FILE_SOCKET)
5851 { 5856 {
5852 if (cmd == F_SETFL && options == O_NDELAY) 5857 if (cmd == F_SETFL && options == O_NONBLOCK)
5853 { 5858 {
5854 unsigned long nblock = 1; 5859 unsigned long nblock = 1;
5855 int rc = pfn_ioctlsocket (SOCK_HANDLE (s), FIONBIO, &nblock); 5860 int rc = pfn_ioctlsocket (SOCK_HANDLE (s), FIONBIO, &nblock);
diff --git a/src/w32proc.c b/src/w32proc.c
index f35a2da537c..9b111b40e36 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -431,13 +431,14 @@ timer_loop (LPVOID arg)
431 /* Simulate a signal delivered to the thread which installed 431 /* Simulate a signal delivered to the thread which installed
432 the timer, by suspending that thread while the handler 432 the timer, by suspending that thread while the handler
433 runs. */ 433 runs. */
434 DWORD result = SuspendThread (itimer->caller_thread); 434 HANDLE th = itimer->caller_thread;
435 DWORD result = SuspendThread (th);
435 436
436 if (result == (DWORD)-1) 437 if (result == (DWORD)-1)
437 return 2; 438 return 2;
438 439
439 handler (sig); 440 handler (sig);
440 ResumeThread (itimer->caller_thread); 441 ResumeThread (th);
441 } 442 }
442 443
443 /* Update expiration time and loop. */ 444 /* Update expiration time and loop. */
@@ -562,6 +563,7 @@ static int
562start_timer_thread (int which) 563start_timer_thread (int which)
563{ 564{
564 DWORD exit_code; 565 DWORD exit_code;
566 HANDLE th;
565 struct itimer_data *itimer = 567 struct itimer_data *itimer =
566 (which == ITIMER_REAL) ? &real_itimer : &prof_itimer; 568 (which == ITIMER_REAL) ? &real_itimer : &prof_itimer;
567 569
@@ -570,9 +572,29 @@ start_timer_thread (int which)
570 && exit_code == STILL_ACTIVE) 572 && exit_code == STILL_ACTIVE)
571 return 0; 573 return 0;
572 574
575 /* Clean up after possibly exited thread. */
576 if (itimer->timer_thread)
577 {
578 CloseHandle (itimer->timer_thread);
579 itimer->timer_thread = NULL;
580 }
581 if (itimer->caller_thread)
582 {
583 CloseHandle (itimer->caller_thread);
584 itimer->caller_thread = NULL;
585 }
586
573 /* Start a new thread. */ 587 /* Start a new thread. */
588 if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
589 GetCurrentProcess (), &th, 0, FALSE,
590 DUPLICATE_SAME_ACCESS))
591 {
592 errno = ESRCH;
593 return -1;
594 }
574 itimer->terminate = 0; 595 itimer->terminate = 0;
575 itimer->type = which; 596 itimer->type = which;
597 itimer->caller_thread = th;
576 /* Request that no more than 64KB of stack be reserved for this 598 /* Request that no more than 64KB of stack be reserved for this
577 thread, to avoid reserving too much memory, which would get in 599 thread, to avoid reserving too much memory, which would get in
578 the way of threads we start to wait for subprocesses. See also 600 the way of threads we start to wait for subprocesses. See also
@@ -591,7 +613,7 @@ start_timer_thread (int which)
591 /* This is needed to make sure that the timer thread running for 613 /* This is needed to make sure that the timer thread running for
592 profiling gets CPU as soon as the Sleep call terminates. */ 614 profiling gets CPU as soon as the Sleep call terminates. */
593 if (which == ITIMER_PROF) 615 if (which == ITIMER_PROF)
594 SetThreadPriority (itimer->caller_thread, THREAD_PRIORITY_TIME_CRITICAL); 616 SetThreadPriority (itimer->timer_thread, THREAD_PRIORITY_TIME_CRITICAL);
595 617
596 return 0; 618 return 0;
597} 619}
@@ -626,17 +648,9 @@ getitimer (int which, struct itimerval *value)
626 648
627 itimer = (which == ITIMER_REAL) ? &real_itimer : &prof_itimer; 649 itimer = (which == ITIMER_REAL) ? &real_itimer : &prof_itimer;
628 650
629 if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
630 GetCurrentProcess (), &itimer->caller_thread, 0,
631 FALSE, DUPLICATE_SAME_ACCESS))
632 {
633 errno = ESRCH;
634 return -1;
635 }
636
637 ticks_now = w32_get_timer_time ((which == ITIMER_REAL) 651 ticks_now = w32_get_timer_time ((which == ITIMER_REAL)
638 ? NULL 652 ? NULL
639 : itimer->caller_thread); 653 : GetCurrentThread ());
640 654
641 t_expire = &itimer->expire; 655 t_expire = &itimer->expire;
642 t_reload = &itimer->reload; 656 t_reload = &itimer->reload;
@@ -775,7 +789,6 @@ alarm (int seconds)
775/* Child process management list. */ 789/* Child process management list. */
776int child_proc_count = 0; 790int child_proc_count = 0;
777child_process child_procs[ MAX_CHILDREN ]; 791child_process child_procs[ MAX_CHILDREN ];
778child_process *dead_child = NULL;
779 792
780static DWORD WINAPI reader_thread (void *arg); 793static DWORD WINAPI reader_thread (void *arg);
781 794
@@ -1028,9 +1041,6 @@ create_child (char *exe, char *cmdline, char *env, int is_gui_app,
1028 if (cp->pid < 0) 1041 if (cp->pid < 0)
1029 cp->pid = -cp->pid; 1042 cp->pid = -cp->pid;
1030 1043
1031 /* pid must fit in a Lisp_Int */
1032 cp->pid = cp->pid & INTMASK;
1033
1034 *pPid = cp->pid; 1044 *pPid = cp->pid;
1035 1045
1036 return TRUE; 1046 return TRUE;
@@ -1106,55 +1116,110 @@ reap_subprocess (child_process *cp)
1106 delete_child (cp); 1116 delete_child (cp);
1107} 1117}
1108 1118
1109/* Wait for any of our existing child processes to die 1119/* Wait for a child process specified by PID, or for any of our
1110 When it does, close its handle 1120 existing child processes (if PID is nonpositive) to die. When it
1111 Return the pid and fill in the status if non-NULL. */ 1121 does, close its handle. Return the pid of the process that died
1122 and fill in STATUS if non-NULL. */
1112 1123
1113int 1124pid_t
1114sys_wait (int *status) 1125waitpid (pid_t pid, int *status, int options)
1115{ 1126{
1116 DWORD active, retval; 1127 DWORD active, retval;
1117 int nh; 1128 int nh;
1118 int pid;
1119 child_process *cp, *cps[MAX_CHILDREN]; 1129 child_process *cp, *cps[MAX_CHILDREN];
1120 HANDLE wait_hnd[MAX_CHILDREN]; 1130 HANDLE wait_hnd[MAX_CHILDREN];
1131 DWORD timeout_ms;
1132 int dont_wait = (options & WNOHANG) != 0;
1121 1133
1122 nh = 0; 1134 nh = 0;
1123 if (dead_child != NULL) 1135 /* According to Posix:
1136
1137 PID = -1 means status is requested for any child process.
1138
1139 PID > 0 means status is requested for a single child process
1140 whose pid is PID.
1141
1142 PID = 0 means status is requested for any child process whose
1143 process group ID is equal to that of the calling process. But
1144 since Windows has only a limited support for process groups (only
1145 for console processes and only for the purposes of passing
1146 Ctrl-BREAK signal to them), and since we have no documented way
1147 of determining whether a given process belongs to our group, we
1148 treat 0 as -1.
1149
1150 PID < -1 means status is requested for any child process whose
1151 process group ID is equal to the absolute value of PID. Again,
1152 since we don't support process groups, we treat that as -1. */
1153 if (pid > 0)
1124 { 1154 {
1125 /* We want to wait for a specific child */ 1155 int our_child = 0;
1126 wait_hnd[nh] = dead_child->procinfo.hProcess; 1156
1127 cps[nh] = dead_child; 1157 /* We are requested to wait for a specific child. */
1128 if (!wait_hnd[nh]) emacs_abort (); 1158 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
1129 nh++; 1159 {
1130 active = 0; 1160 /* Some child_procs might be sockets; ignore them. Also
1131 goto get_result; 1161 ignore subprocesses whose output is not yet completely
1162 read. */
1163 if (CHILD_ACTIVE (cp)
1164 && cp->procinfo.hProcess
1165 && cp->pid == pid)
1166 {
1167 our_child = 1;
1168 break;
1169 }
1170 }
1171 if (our_child)
1172 {
1173 if (cp->fd < 0 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0)
1174 {
1175 wait_hnd[nh] = cp->procinfo.hProcess;
1176 cps[nh] = cp;
1177 nh++;
1178 }
1179 else if (dont_wait)
1180 {
1181 /* PID specifies our subprocess, but its status is not
1182 yet available. */
1183 return 0;
1184 }
1185 }
1186 if (nh == 0)
1187 {
1188 /* No such child process, or nothing to wait for, so fail. */
1189 errno = ECHILD;
1190 return -1;
1191 }
1132 } 1192 }
1133 else 1193 else
1134 { 1194 {
1135 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) 1195 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
1136 /* some child_procs might be sockets; ignore them */ 1196 {
1137 if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess 1197 if (CHILD_ACTIVE (cp)
1138 && (cp->fd < 0 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0)) 1198 && cp->procinfo.hProcess
1139 { 1199 && (cp->fd < 0 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0))
1140 wait_hnd[nh] = cp->procinfo.hProcess; 1200 {
1141 cps[nh] = cp; 1201 wait_hnd[nh] = cp->procinfo.hProcess;
1142 nh++; 1202 cps[nh] = cp;
1143 } 1203 nh++;
1204 }
1205 }
1206 if (nh == 0)
1207 {
1208 /* Nothing to wait on, so fail. */
1209 errno = ECHILD;
1210 return -1;
1211 }
1144 } 1212 }
1145 1213
1146 if (nh == 0) 1214 if (dont_wait)
1147 { 1215 timeout_ms = 0;
1148 /* Nothing to wait on, so fail */ 1216 else
1149 errno = ECHILD; 1217 timeout_ms = 1000; /* check for quit about once a second. */
1150 return -1;
1151 }
1152 1218
1153 do 1219 do
1154 { 1220 {
1155 /* Check for quit about once a second. */
1156 QUIT; 1221 QUIT;
1157 active = WaitForMultipleObjects (nh, wait_hnd, FALSE, 1000); 1222 active = WaitForMultipleObjects (nh, wait_hnd, FALSE, timeout_ms);
1158 } while (active == WAIT_TIMEOUT); 1223 } while (active == WAIT_TIMEOUT);
1159 1224
1160 if (active == WAIT_FAILED) 1225 if (active == WAIT_FAILED)
@@ -1175,7 +1240,6 @@ sys_wait (int *status)
1175 else 1240 else
1176 emacs_abort (); 1241 emacs_abort ();
1177 1242
1178get_result:
1179 if (!GetExitCodeProcess (wait_hnd[active], &retval)) 1243 if (!GetExitCodeProcess (wait_hnd[active], &retval))
1180 { 1244 {
1181 DebPrint (("Wait.GetExitCodeProcess failed with %lu\n", 1245 DebPrint (("Wait.GetExitCodeProcess failed with %lu\n",
@@ -1184,8 +1248,10 @@ get_result:
1184 } 1248 }
1185 if (retval == STILL_ACTIVE) 1249 if (retval == STILL_ACTIVE)
1186 { 1250 {
1187 /* Should never happen */ 1251 /* Should never happen. */
1188 DebPrint (("Wait.WaitForMultipleObjects returned an active process\n")); 1252 DebPrint (("Wait.WaitForMultipleObjects returned an active process\n"));
1253 if (pid > 0 && dont_wait)
1254 return 0;
1189 errno = EINVAL; 1255 errno = EINVAL;
1190 return -1; 1256 return -1;
1191 } 1257 }
@@ -1199,6 +1265,8 @@ get_result:
1199 else 1265 else
1200 retval <<= 8; 1266 retval <<= 8;
1201 1267
1268 if (pid > 0 && active != 0)
1269 emacs_abort ();
1202 cp = cps[active]; 1270 cp = cps[active];
1203 pid = cp->pid; 1271 pid = cp->pid;
1204#ifdef FULL_DEBUG 1272#ifdef FULL_DEBUG
@@ -1987,9 +2055,7 @@ count_children:
1987 DebPrint (("select calling SIGCHLD handler for pid %d\n", 2055 DebPrint (("select calling SIGCHLD handler for pid %d\n",
1988 cp->pid)); 2056 cp->pid));
1989#endif 2057#endif
1990 dead_child = cp;
1991 sig_handlers[SIGCHLD] (SIGCHLD); 2058 sig_handlers[SIGCHLD] (SIGCHLD);
1992 dead_child = NULL;
1993 } 2059 }
1994 } 2060 }
1995 else if (fdindex[active] == -1) 2061 else if (fdindex[active] == -1)
diff --git a/src/w32select.c b/src/w32select.c
index 1b10c74cfe9..6a2a840f914 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -74,8 +74,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
74 74
75#include <config.h> 75#include <config.h>
76#include "lisp.h" 76#include "lisp.h"
77#include "w32term.h" /* for all of the w32 includes */
78#include "w32common.h" /* os_subtype */ 77#include "w32common.h" /* os_subtype */
78#include "w32term.h" /* for all of the w32 includes */
79#include "keyboard.h" 79#include "keyboard.h"
80#include "blockinput.h" 80#include "blockinput.h"
81#include "charset.h" 81#include "charset.h"
diff --git a/src/w32term.h b/src/w32term.h
index 72fb8a76e35..83535b8faa3 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -745,6 +745,21 @@ extern int w32_system_caret_height;
745extern int w32_system_caret_x; 745extern int w32_system_caret_x;
746extern int w32_system_caret_y; 746extern int w32_system_caret_y;
747 747
748#ifdef _MSC_VER
749#ifndef EnumSystemLocales
750/* MSVC headers define these only for _WIN32_WINNT >= 0x0500. */
751typedef BOOL (CALLBACK *LOCALE_ENUMPROCA)(LPSTR);
752typedef BOOL (CALLBACK *LOCALE_ENUMPROCW)(LPWSTR);
753BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA,DWORD);
754BOOL WINAPI EnumSystemLocalesW(LOCALE_ENUMPROCW,DWORD)
755#ifdef UNICODE
756#define EnumSystemLocales EnumSystemLocalesW
757#else
758#define EnumSystemLocales EnumSystemLocalesA
759#endif
760#endif
761#endif
762
748#if EMACSDEBUG 763#if EMACSDEBUG
749extern const char* 764extern const char*
750w32_name_of_message (UINT msg); 765w32_name_of_message (UINT msg);
diff --git a/src/xfaces.c b/src/xfaces.c
index daf329791c1..1e27d5cc043 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -2870,6 +2870,12 @@ FRAME 0 means change the face on all frames, and change the default
2870 Lisp_Object key, val, list; 2870 Lisp_Object key, val, list;
2871 2871
2872 list = value; 2872 list = value;
2873 /* FIXME? This errs on the side of acceptance. Eg it accepts:
2874 (defface foo '((t :underline 'foo) "doc")
2875 Maybe this is intentional, maybe it isn't.
2876 Non-nil symbols other than t are not documented as being valid.
2877 Eg compare with inverse-video, which explicitly rejects them.
2878 */
2873 valid_p = 1; 2879 valid_p = 1;
2874 2880
2875 while (!NILP (CAR_SAFE(list))) 2881 while (!NILP (CAR_SAFE(list)))
@@ -5660,6 +5666,8 @@ realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE])
5660 face->underline_defaulted_p = 1; 5666 face->underline_defaulted_p = 1;
5661 face->underline_type = FACE_UNDER_LINE; 5667 face->underline_type = FACE_UNDER_LINE;
5662 5668
5669 /* FIXME? This is also not robust about checking the precise form.
5670 See comments in Finternal_set_lisp_face_attribute. */
5663 while (CONSP (underline)) 5671 while (CONSP (underline))
5664 { 5672 {
5665 Lisp_Object keyword, value; 5673 Lisp_Object keyword, value;