aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Laws2015-02-27 12:43:30 +0200
committerEli Zaretskii2015-02-27 12:43:30 +0200
commit805fe507087b9675a010a30a8a8840587ffdf5be (patch)
tree9b91858096495590692d1f5fe814cb64d9712f8b
parent6ef14349fa73922473ba8202e256f20e17661b25 (diff)
downloademacs-805fe507087b9675a010a30a8a8840587ffdf5be.tar.gz
emacs-805fe507087b9675a010a30a8a8840587ffdf5be.zip
Support daemon mode on MS-Windows (bug#19688)
src/emacs.c <w32_daemon_event> [WINDOWSNT]: New global var. (main) [WINDOWSNT]: Initialize it to NULL. Create the event to signal clients we are ready for connections. (Fdaemon_initialized): Use DAEMON_RUNNING. [WINDOWSNT]: MS-Windows specific code to signal clients we are ready for connections. src/lisp.h (DAEMON_RUNNING): New macro, encapsulates Posix and MS-Windows conditions for running in daemon mode. src/minibuf.c (read_minibuf): Use DAEMON_RUNNING. src/keyboard.c (kbd_buffer_get_event): Use DAEMON_RUNNING. src/dispnew.c (init_display) [WINDOWSNT]: Initialize frames/terminal even in daemon mode. nt/inc/ms-w32.h (W32_DAEMON_EVENT): New macro. lib-src/emacsclient.c (decode_options) [WINDOWSNT]: Don't reject empty arguments for --alternate-editor. (print_help_and_exit) [WINDOWSNT]: Don't refrain from advertising empty arguments for --alternate-editor. (start_daemon_and_retry_set_socket) [WINDOWSNT]: MS-Windows specific code to start Emacs in daemon mode and wait for it to be ready for client connections. lisp/server.el (server-process-filter): Force GUI frames on MS-Windows in daemon mode, even if a TTY frame was requested. lisp/frameset.el (frameset-keep-original-display-p): Don't assume windows-nt cannot be in daemon mode. lisp/frame.el (window-system-for-display): Don't assume windows-nt cannot be in daemon mode.
-rw-r--r--lib-src/ChangeLog11
-rw-r--r--lib-src/emacsclient.c81
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/frame.el3
-rw-r--r--lisp/frameset.el4
-rw-r--r--lisp/server.el12
-rw-r--r--nt/ChangeLog5
-rw-r--r--nt/inc/ms-w32.h2
-rw-r--r--src/ChangeLog20
-rw-r--r--src/dispnew.c5
-rw-r--r--src/emacs.c37
-rw-r--r--src/keyboard.c2
-rw-r--r--src/lisp.h9
-rw-r--r--src/minibuf.c2
14 files changed, 179 insertions, 26 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 5c55bcea506..83855afa675 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,14 @@
12015-02-27 Mark Laws <mdl@60hz.org>
2
3 Support daemon mode on MS-Windows (bug#19688)
4 * emacsclient.c (decode_options) [WINDOWSNT]: Don't reject empty
5 arguments for --alternate-editor.
6 (print_help_and_exit) [WINDOWSNT]: Don't refrain from advertising
7 empty arguments for --alternate-editor.
8 (start_daemon_and_retry_set_socket) [WINDOWSNT]: MS-Windows
9 specific code to start Emacs in daemon mode and wait for it to be
10 ready for client connections.
11
12015-02-23 Pete Williamson <petewil0@googlemail.com> (tiny change) 122015-02-23 Pete Williamson <petewil0@googlemail.com> (tiny change)
2 13
3 Use ${EXEEXT} more uniformly in makefiles 14 Use ${EXEEXT} more uniformly in makefiles
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index a04dda6408f..806275f5b1d 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -595,13 +595,6 @@ decode_options (int argc, char **argv)
595 display = NULL; 595 display = NULL;
596 tty = 1; 596 tty = 1;
597 } 597 }
598
599 if (alternate_editor && alternate_editor[0] == '\0')
600 {
601 message (true, "--alternate-editor argument or ALTERNATE_EDITOR variable cannot be\n\
602an empty string");
603 exit (EXIT_FAILURE);
604 }
605#endif /* WINDOWSNT */ 598#endif /* WINDOWSNT */
606} 599}
607 600
@@ -642,10 +635,8 @@ The following OPTIONS are accepted:\n\
642 Set filename of the TCP authentication file\n\ 635 Set filename of the TCP authentication file\n\
643-a EDITOR, --alternate-editor=EDITOR\n\ 636-a EDITOR, --alternate-editor=EDITOR\n\
644 Editor to fallback to if the server is not running\n" 637 Editor to fallback to if the server is not running\n"
645#ifndef WINDOWSNT
646" If EDITOR is the empty string, start Emacs in daemon\n\ 638" If EDITOR is the empty string, start Emacs in daemon\n\
647 mode and try connecting again\n" 639 mode and try connecting again\n"
648#endif /* not WINDOWSNT */
649"\n\ 640"\n\
650Report bugs with M-x report-emacs-bug.\n"); 641Report bugs with M-x report-emacs-bug.\n");
651 exit (EXIT_SUCCESS); 642 exit (EXIT_SUCCESS);
@@ -1511,7 +1502,77 @@ start_daemon_and_retry_set_socket (void)
1511 execvp ("emacs", d_argv); 1502 execvp ("emacs", d_argv);
1512 message (true, "%s: error starting emacs daemon\n", progname); 1503 message (true, "%s: error starting emacs daemon\n", progname);
1513 } 1504 }
1514#endif /* WINDOWSNT */ 1505#else /* WINDOWSNT */
1506 DWORD wait_result;
1507 HANDLE w32_daemon_event;
1508 STARTUPINFO si;
1509 PROCESS_INFORMATION pi;
1510
1511 ZeroMemory (&si, sizeof si);
1512 si.cb = sizeof si;
1513 ZeroMemory (&pi, sizeof pi);
1514
1515 /* We start Emacs in daemon mode, and then wait for it to signal us
1516 it is ready to accept client connections, by asserting an event
1517 whose name is known to the daemon (defined by nt/inc/ms-w32.h). */
1518
1519 if (!CreateProcess (NULL, "emacs --daemon", NULL, NULL, FALSE,
1520 CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
1521 {
1522 char* msg = NULL;
1523
1524 FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM
1525 | FORMAT_MESSAGE_ALLOCATE_BUFFER
1526 | FORMAT_MESSAGE_ARGUMENT_ARRAY,
1527 NULL, GetLastError (), 0, (LPTSTR)&msg, 0, NULL);
1528 message (true, "%s: error starting emacs daemon (%s)\n", progname, msg);
1529 exit (EXIT_FAILURE);
1530 }
1531
1532 w32_daemon_event = CreateEvent (NULL, TRUE, FALSE, W32_DAEMON_EVENT);
1533 if (w32_daemon_event == NULL)
1534 {
1535 message (true, "Couldn't create Windows daemon event");
1536 exit (EXIT_FAILURE);
1537 }
1538 if ((wait_result = WaitForSingleObject (w32_daemon_event, INFINITE))
1539 != WAIT_OBJECT_0)
1540 {
1541 char *msg = NULL;
1542
1543 switch (wait_result)
1544 {
1545 case WAIT_ABANDONED:
1546 msg = "The daemon exited unexpectedly";
1547 break;
1548 case WAIT_TIMEOUT:
1549 /* Can't happen due to INFINITE. */
1550 default:
1551 case WAIT_FAILED:
1552 FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM
1553 | FORMAT_MESSAGE_ALLOCATE_BUFFER
1554 | FORMAT_MESSAGE_ARGUMENT_ARRAY,
1555 NULL, GetLastError (), 0, (LPTSTR)&msg, 0, NULL);
1556 break;
1557 }
1558 message (true, "Error: Could not start the Emacs daemon: %s\n", msg);
1559 exit (EXIT_FAILURE);
1560 }
1561 CloseHandle (w32_daemon_event);
1562
1563 /* Try connecting, the daemon should have started by now. */
1564 /* It's just a progress message, so don't pop a dialog if this is
1565 emacsclientw. */
1566 if (!w32_window_app ())
1567 message (true,
1568 "Emacs daemon should have started, trying to connect again\n");
1569 if ((emacs_socket = set_socket (1)) == INVALID_SOCKET)
1570 {
1571 message (true,
1572 "Error: Cannot connect even after starting the Emacs daemon\n");
1573 exit (EXIT_FAILURE);
1574 }
1575#endif /* WINDOWSNT */
1515} 1576}
1516 1577
1517int 1578int
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e9f62365f03..b9681d35cf0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12015-02-27 Mark Laws <mdl@60hz.org>
2
3 Support daemon mode on MS-Windows (bug#19688)
4 * server.el (server-process-filter): Force GUI frames on
5 MS-Windows in daemon mode, even if a TTY frame was requested.
6
7 * frameset.el (frameset-keep-original-display-p): Don't assume
8 windows-nt cannot be in daemon mode.
9
10 * frame.el (window-system-for-display): Don't assume windows-nt
11 cannot be in daemon mode.
12
12015-02-26 Ivan Shmakov <ivan@siamics.net> 132015-02-26 Ivan Shmakov <ivan@siamics.net>
2 14
3 * faces.el (face-list-p): Split from face-at-point. 15 * faces.el (face-list-p): Split from face-at-point.
diff --git a/lisp/frame.el b/lisp/frame.el
index 0096ef9696a..c81ee9bfa61 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -546,7 +546,8 @@ is not considered (see `next-frame')."
546Return nil if we don't know how to interpret DISPLAY." 546Return nil if we don't know how to interpret DISPLAY."
547 ;; MS-Windows doesn't know how to create a GUI frame in a -nw session. 547 ;; MS-Windows doesn't know how to create a GUI frame in a -nw session.
548 (if (and (eq system-type 'windows-nt) 548 (if (and (eq system-type 'windows-nt)
549 (null (window-system))) 549 (null (window-system))
550 (not (daemonp)))
550 nil 551 nil
551 (cl-loop for descriptor in display-format-alist 552 (cl-loop for descriptor in display-format-alist
552 for pattern = (car descriptor) 553 for pattern = (car descriptor)
diff --git a/lisp/frameset.el b/lisp/frameset.el
index 4a0637439db..17fe39be844 100644
--- a/lisp/frameset.el
+++ b/lisp/frameset.el
@@ -1022,8 +1022,8 @@ Internal use only."
1022(defun frameset-keep-original-display-p (force-display) 1022(defun frameset-keep-original-display-p (force-display)
1023 "True if saved frames' displays should be honored. 1023 "True if saved frames' displays should be honored.
1024For the meaning of FORCE-DISPLAY, see `frameset-restore'." 1024For the meaning of FORCE-DISPLAY, see `frameset-restore'."
1025 (cond ((daemonp) t) 1025 (cond ((eq system-type 'windows-nt) nil) ;; Does ns support more than one display?
1026 ((eq system-type 'windows-nt) nil) ;; Does ns support more than one display? 1026 ((daemonp) t)
1027 (t (not force-display)))) 1027 (t (not force-display))))
1028 1028
1029(defun frameset-minibufferless-first-p (frame1 _frame2) 1029(defun frameset-minibufferless-first-p (frame1 _frame2)
diff --git a/lisp/server.el b/lisp/server.el
index 166cd44bb2e..9585b1755c6 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1139,9 +1139,12 @@ The following commands are accepted by the client:
1139 ;; frame. If running a GUI server, force the frame 1139 ;; frame. If running a GUI server, force the frame
1140 ;; type to GUI. (Cygwin is perfectly happy with 1140 ;; type to GUI. (Cygwin is perfectly happy with
1141 ;; multi-tty support, so don't override the user's 1141 ;; multi-tty support, so don't override the user's
1142 ;; choice there.) 1142 ;; choice there.) In daemon mode on Windows, we can't
1143 ;; make tty frames, so force the frame type to GUI
1144 ;; there too.
1143 (when (and (eq system-type 'windows-nt) 1145 (when (and (eq system-type 'windows-nt)
1144 (eq window-system 'w32)) 1146 (or (daemonp)
1147 (eq window-system 'w32)))
1145 (push "-window-system" args-left))) 1148 (push "-window-system" args-left)))
1146 1149
1147 ;; -position LINE[:COLUMN]: Set point to the given 1150 ;; -position LINE[:COLUMN]: Set point to the given
@@ -1215,7 +1218,10 @@ The following commands are accepted by the client:
1215 terminal-frame))))) 1218 terminal-frame)))))
1216 (setq tty-name nil tty-type nil) 1219 (setq tty-name nil tty-type nil)
1217 (if display (server-select-display display))) 1220 (if display (server-select-display display)))
1218 ((eq tty-name 'window-system) 1221 ((or (and (eq system-type 'windows-nt)
1222 (daemonp)
1223 (setq display "w32"))
1224 (eq tty-name 'window-system))
1219 (server-create-window-system-frame display nowait proc 1225 (server-create-window-system-frame display nowait proc
1220 parent-id 1226 parent-id
1221 frame-parameters)) 1227 frame-parameters))
diff --git a/nt/ChangeLog b/nt/ChangeLog
index b9966fb27d8..240f58c850b 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,8 @@
12015-02-27 Mark Laws <mdl@60hz.org>
2
3 Support daemon mode on MS-Windows (bug#19688)
4 * inc/ms-w32.h (W32_DAEMON_EVENT): New macro.
5
12015-01-16 Eli Zaretskii <eliz@gnu.org> 62015-01-16 Eli Zaretskii <eliz@gnu.org>
2 7
3 * Makefile.in (AM_V_CC, am__v_CC_, am__v_CC_0, am__v_CC_1) 8 * Makefile.in (AM_V_CC, am__v_CC_, am__v_CC_0, am__v_CC_1)
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index adac2e3b4a1..c06ed588818 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -597,5 +597,7 @@ extern void _DebPrint (const char *fmt, ...);
597#endif 597#endif
598#endif 598#endif
599 599
600/* Event name for when emacsclient starts the Emacs daemon on Windows. */
601#define W32_DAEMON_EVENT "EmacsServerEvent"
600 602
601/* ============================================================ */ 603/* ============================================================ */
diff --git a/src/ChangeLog b/src/ChangeLog
index bf4043666c6..61bb321649f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,23 @@
12015-02-27 Mark Laws <mdl@60hz.org>
2
3 Support daemon mode on MS-Windows (bug#19688)
4 * emacs.c <w32_daemon_event> [WINDOWSNT]: New global var.
5 (main) [WINDOWSNT]: Initialize it to NULL. Create the event to
6 signal clients we are ready for connections.
7 (Fdaemon_initialized): Use DAEMON_RUNNING.
8 [WINDOWSNT]: MS-Windows specific code to signal clients we are
9 ready for connections.
10
11 * lisp.h (DAEMON_RUNNING): New macro, encapsulates Posix and
12 MS-Windows conditions for running in daemon mode.
13
14 * minibuf.c (read_minibuf): Use DAEMON_RUNNING.
15
16 * keyboard.c (kbd_buffer_get_event): Use DAEMON_RUNNING.
17
18 * dispnew.c (init_display) [WINDOWSNT]: Initialize frames/terminal
19 even in daemon mode.
20
12015-02-26 Jan Djärv <jan.h.d@swipnet.se> 212015-02-26 Jan Djärv <jan.h.d@swipnet.se>
2 22
3 * xmenu.c (create_and_show_popup_menu): Call XTranslateCoordinates, 23 * xmenu.c (create_and_show_popup_menu): Call XTranslateCoordinates,
diff --git a/src/dispnew.c b/src/dispnew.c
index a1782913154..6bc24697cb7 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5949,9 +5949,12 @@ init_display (void)
5949 } 5949 }
5950#endif /* SIGWINCH */ 5950#endif /* SIGWINCH */
5951 5951
5952 /* If running as a daemon, no need to initialize any frames/terminal. */ 5952 /* If running as a daemon, no need to initialize any frames/terminal,
5953 except on Windows, where we at least want to initialize it. */
5954#ifndef WINDOWSNT
5953 if (IS_DAEMON) 5955 if (IS_DAEMON)
5954 return; 5956 return;
5957#endif
5955 5958
5956 /* If the user wants to use a window system, we shouldn't bother 5959 /* If the user wants to use a window system, we shouldn't bother
5957 initializing the terminal. This is especially important when the 5960 initializing the terminal. This is especially important when the
diff --git a/src/emacs.c b/src/emacs.c
index cb0c8417794..ca5633da2dd 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -195,9 +195,13 @@ bool no_site_lisp;
195/* Name for the server started by the daemon.*/ 195/* Name for the server started by the daemon.*/
196static char *daemon_name; 196static char *daemon_name;
197 197
198#ifndef WINDOWSNT
198/* Pipe used to send exit notification to the daemon parent at 199/* Pipe used to send exit notification to the daemon parent at
199 startup. */ 200 startup. */
200int daemon_pipe[2]; 201int daemon_pipe[2];
202#else
203HANDLE w32_daemon_event;
204#endif
201 205
202/* Save argv and argc. */ 206/* Save argv and argc. */
203char **initial_argv; 207char **initial_argv;
@@ -982,8 +986,12 @@ main (int argc, char **argv)
982 exit (0); 986 exit (0);
983 } 987 }
984 988
989#ifndef WINDOWSNT
985 /* Make sure IS_DAEMON starts up as false. */ 990 /* Make sure IS_DAEMON starts up as false. */
986 daemon_pipe[1] = 0; 991 daemon_pipe[1] = 0;
992#else
993 w32_daemon_event = NULL;
994#endif
987 995
988 if (argmatch (argv, argc, "-daemon", "--daemon", 5, NULL, &skip_args) 996 if (argmatch (argv, argc, "-daemon", "--daemon", 5, NULL, &skip_args)
989 || argmatch (argv, argc, "-daemon", "--daemon", 5, &dname_arg, &skip_args)) 997 || argmatch (argv, argc, "-daemon", "--daemon", 5, &dname_arg, &skip_args))
@@ -1107,16 +1115,25 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1107 } 1115 }
1108#endif /* DAEMON_MUST_EXEC */ 1116#endif /* DAEMON_MUST_EXEC */
1109 1117
1110 if (dname_arg)
1111 daemon_name = xstrdup (dname_arg);
1112 /* Close unused reading end of the pipe. */ 1118 /* Close unused reading end of the pipe. */
1113 emacs_close (daemon_pipe[0]); 1119 emacs_close (daemon_pipe[0]);
1114 1120
1115 setsid (); 1121 setsid ();
1116#else /* DOS_NT */ 1122#elif defined(WINDOWSNT)
1123 /* Indicate that we want daemon mode. */
1124 w32_daemon_event = CreateEvent (NULL, TRUE, FALSE, W32_DAEMON_EVENT);
1125 if (w32_daemon_event == NULL)
1126 {
1127 fprintf (stderr, "Couldn't create MS-Windows event for daemon: %s\n",
1128 w32_strerror (0));
1129 exit (1);
1130 }
1131#else /* MSDOS */
1117 fprintf (stderr, "This platform does not support the -daemon flag.\n"); 1132 fprintf (stderr, "This platform does not support the -daemon flag.\n");
1118 exit (1); 1133 exit (1);
1119#endif /* DOS_NT */ 1134#endif /* MSDOS */
1135 if (dname_arg)
1136 daemon_name = xstrdup (dname_arg);
1120 } 1137 }
1121 1138
1122#if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC \ 1139#if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC \
@@ -2313,17 +2330,18 @@ This finishes the daemonization process by doing the other half of detaching
2313from the parent process and its tty file descriptors. */) 2330from the parent process and its tty file descriptors. */)
2314 (void) 2331 (void)
2315{ 2332{
2316 int nfd;
2317 bool err = 0; 2333 bool err = 0;
2318 2334
2319 if (!IS_DAEMON) 2335 if (!IS_DAEMON)
2320 error ("This function can only be called if emacs is run as a daemon"); 2336 error ("This function can only be called if emacs is run as a daemon");
2321 2337
2322 if (daemon_pipe[1] < 0) 2338 if (!DAEMON_RUNNING)
2323 error ("The daemon has already been initialized"); 2339 error ("The daemon has already been initialized");
2324 2340
2325 if (NILP (Vafter_init_time)) 2341 if (NILP (Vafter_init_time))
2326 error ("This function can only be called after loading the init files"); 2342 error ("This function can only be called after loading the init files");
2343#ifndef WINDOWSNT
2344 int nfd;
2327 2345
2328 /* Get rid of stdin, stdout and stderr. */ 2346 /* Get rid of stdin, stdout and stderr. */
2329 nfd = emacs_open ("/dev/null", O_RDWR, 0); 2347 nfd = emacs_open ("/dev/null", O_RDWR, 0);
@@ -2344,6 +2362,13 @@ from the parent process and its tty file descriptors. */)
2344 err |= emacs_close (daemon_pipe[1]) != 0; 2362 err |= emacs_close (daemon_pipe[1]) != 0;
2345 /* Set it to an invalid value so we know we've already run this function. */ 2363 /* Set it to an invalid value so we know we've already run this function. */
2346 daemon_pipe[1] = -1; 2364 daemon_pipe[1] = -1;
2365#else /* WINDOWSNT */
2366 /* Signal the waiting emacsclient process. */
2367 err |= SetEvent (w32_daemon_event) == 0;
2368 err |= CloseHandle (w32_daemon_event) == 0;
2369 /* Set it to an invalid value so we know we've already run this function. */
2370 w32_daemon_event = INVALID_HANDLE_VALUE;
2371#endif
2347 2372
2348 if (err) 2373 if (err)
2349 error ("I/O error during daemon initialization"); 2374 error ("I/O error during daemon initialization");
diff --git a/src/keyboard.c b/src/keyboard.c
index c2174539ea7..e1c5691324d 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3853,7 +3853,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3853 if (noninteractive 3853 if (noninteractive
3854 /* In case we are running as a daemon, only do this before 3854 /* In case we are running as a daemon, only do this before
3855 detaching from the terminal. */ 3855 detaching from the terminal. */
3856 || (IS_DAEMON && daemon_pipe[1] >= 0)) 3856 || (IS_DAEMON && DAEMON_RUNNING))
3857 { 3857 {
3858 int c = getchar (); 3858 int c = getchar ();
3859 XSETINT (obj, c); 3859 XSETINT (obj, c);
diff --git a/src/lisp.h b/src/lisp.h
index 9764b096ef0..fb436776121 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4222,9 +4222,16 @@ extern bool noninteractive;
4222extern bool no_site_lisp; 4222extern bool no_site_lisp;
4223 4223
4224/* Pipe used to send exit notification to the daemon parent at 4224/* Pipe used to send exit notification to the daemon parent at
4225 startup. */ 4225 startup. On Windows, we use a kernel event instead. */
4226#ifndef WINDOWSNT
4226extern int daemon_pipe[2]; 4227extern int daemon_pipe[2];
4227#define IS_DAEMON (daemon_pipe[1] != 0) 4228#define IS_DAEMON (daemon_pipe[1] != 0)
4229#define DAEMON_RUNNING (daemon_pipe[1] >= 0)
4230#else /* WINDOWSNT */
4231extern void *w32_daemon_event;
4232#define IS_DAEMON (w32_daemon_event != NULL)
4233#define DAEMON_RUNNING (w32_daemon_event != INVALID_HANDLE_VALUE)
4234#endif
4228 4235
4229/* True if handling a fatal error already. */ 4236/* True if handling a fatal error already. */
4230extern bool fatal_error_in_progress; 4237extern bool fatal_error_in_progress;
diff --git a/src/minibuf.c b/src/minibuf.c
index 2dc5c544457..e7c288b251b 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -459,7 +459,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
459 if ((noninteractive 459 if ((noninteractive
460 /* In case we are running as a daemon, only do this before 460 /* In case we are running as a daemon, only do this before
461 detaching from the terminal. */ 461 detaching from the terminal. */
462 || (IS_DAEMON && (daemon_pipe[1] >= 0))) 462 || (IS_DAEMON && DAEMON_RUNNING))
463 && NILP (Vexecuting_kbd_macro)) 463 && NILP (Vexecuting_kbd_macro))
464 { 464 {
465 val = read_minibuf_noninteractive (map, initial, prompt, 465 val = read_minibuf_noninteractive (map, initial, prompt,