summaryrefslogtreecommitdiff
path: root/src/w32.c
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1996-05-17 21:45:30 +0000
committerKarl Heuer <kwzh@gnu.org>1996-05-17 21:45:30 +0000
commit7cf8acc93467b0d987f4e1d7c93e40c95e29f8f9 (patch)
treefc2b542b20f2d9ed33b1b7116dd9c5cd289a408f /src/w32.c
parent34c156ca3e9617c02da3923a7b9106088c88953a (diff)
downloademacs-7cf8acc93467b0d987f4e1d7c93e40c95e29f8f9.tar.gz
(_sys_read_ahead): Handle sleep here.
(sys_read): Not here. (init_ntproc): Initialize can_run_dos_process, dos_process_running.
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/w32.c b/src/w32.c
index fd1d5e10508..540974dad51 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1755,6 +1755,9 @@ sys_pipe (int * phandles)
return rc;
}
+/* From ntproc.c */
+extern Lisp_Object Vwin32_pipe_read_delay;
+
/* Function to do blocking read of one byte, needed to implement
select. It is only allowed on sockets and pipes. */
int
@@ -1781,8 +1784,30 @@ _sys_read_ahead (int fd)
cp->status = STATUS_READ_IN_PROGRESS;
if (fd_info[fd].flags & FILE_PIPE)
- /* Use read to get CRLF translation */
- rc = _read (fd, &cp->chr, sizeof (char));
+ {
+ /* Use read to get CRLF translation */
+ rc = _read (fd, &cp->chr, sizeof (char));
+
+ /* Give subprocess time to buffer some more output for us before
+ reporting that input is available; we need this because Win95
+ connects DOS programs to pipes by making the pipe appear to be
+ the normal console stdout - as a result most DOS programs will
+ write to stdout without buffering, ie. one character at a
+ time. Even some Win32 programs do this - "dir" in a command
+ shell on NT is very slow if we don't do this. */
+ if (rc > 0)
+ {
+ int wait = XINT (Vwin32_pipe_read_delay);
+
+ if (wait > 0)
+ Sleep (wait);
+ else if (wait < 0)
+ while (++wait <= 0)
+ /* Yield remainder of our time slice, effectively giving a
+ temporary priority boost to the child process. */
+ Sleep (0);
+ }
+ }
#ifdef HAVE_SOCKETS
else if (fd_info[fd].flags & FILE_SOCKET)
rc = pfn_recv (SOCK_HANDLE (fd), &cp->chr, sizeof (char), 0);
@@ -1851,8 +1876,6 @@ sys_read (int fd, char * buffer, unsigned int count)
ResetEvent (cp->char_avail);
case STATUS_READ_ACKNOWLEDGED:
- /* Give process time to buffer some more output for us */
- Sleep (50);
break;
default:
@@ -1958,6 +1981,9 @@ term_ntproc ()
#endif
}
+extern BOOL can_run_dos_process;
+extern BOOL dos_process_running;
+
void
init_ntproc ()
{
@@ -2025,6 +2051,10 @@ init_ntproc ()
fdopen (2, "w");
}
+ /* Only allow Emacs to run DOS programs on Win95. */
+ can_run_dos_process = (GetVersion () & 0x80000000);
+ dos_process_running = FALSE;
+
/* unfortunately, atexit depends on implementation of malloc */
/* atexit (term_ntproc); */
signal (SIGABRT, term_ntproc);