diff options
| author | Karl Heuer | 1996-05-17 21:45:30 +0000 |
|---|---|---|
| committer | Karl Heuer | 1996-05-17 21:45:30 +0000 |
| commit | f75543492d72597ece7e4d6727719825bade9228 (patch) | |
| tree | 03a5742b1583f471d7c48651abad5059cae91784 /src | |
| parent | c98e68fc1312ec2d4111b43f937acd5b46f47ae1 (diff) | |
| download | emacs-f75543492d72597ece7e4d6727719825bade9228.tar.gz emacs-f75543492d72597ece7e4d6727719825bade9228.zip | |
(_sys_read_ahead): Handle sleep here.
(sys_read): Not here.
(init_ntproc): Initialize can_run_dos_process, dos_process_running.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 38 |
1 files changed, 34 insertions, 4 deletions
| @@ -1755,6 +1755,9 @@ sys_pipe (int * phandles) | |||
| 1755 | return rc; | 1755 | return rc; |
| 1756 | } | 1756 | } |
| 1757 | 1757 | ||
| 1758 | /* From ntproc.c */ | ||
| 1759 | extern Lisp_Object Vwin32_pipe_read_delay; | ||
| 1760 | |||
| 1758 | /* Function to do blocking read of one byte, needed to implement | 1761 | /* Function to do blocking read of one byte, needed to implement |
| 1759 | select. It is only allowed on sockets and pipes. */ | 1762 | select. It is only allowed on sockets and pipes. */ |
| 1760 | int | 1763 | int |
| @@ -1781,8 +1784,30 @@ _sys_read_ahead (int fd) | |||
| 1781 | cp->status = STATUS_READ_IN_PROGRESS; | 1784 | cp->status = STATUS_READ_IN_PROGRESS; |
| 1782 | 1785 | ||
| 1783 | if (fd_info[fd].flags & FILE_PIPE) | 1786 | if (fd_info[fd].flags & FILE_PIPE) |
| 1784 | /* Use read to get CRLF translation */ | 1787 | { |
| 1785 | rc = _read (fd, &cp->chr, sizeof (char)); | 1788 | /* Use read to get CRLF translation */ |
| 1789 | rc = _read (fd, &cp->chr, sizeof (char)); | ||
| 1790 | |||
| 1791 | /* Give subprocess time to buffer some more output for us before | ||
| 1792 | reporting that input is available; we need this because Win95 | ||
| 1793 | connects DOS programs to pipes by making the pipe appear to be | ||
| 1794 | the normal console stdout - as a result most DOS programs will | ||
| 1795 | write to stdout without buffering, ie. one character at a | ||
| 1796 | time. Even some Win32 programs do this - "dir" in a command | ||
| 1797 | shell on NT is very slow if we don't do this. */ | ||
| 1798 | if (rc > 0) | ||
| 1799 | { | ||
| 1800 | int wait = XINT (Vwin32_pipe_read_delay); | ||
| 1801 | |||
| 1802 | if (wait > 0) | ||
| 1803 | Sleep (wait); | ||
| 1804 | else if (wait < 0) | ||
| 1805 | while (++wait <= 0) | ||
| 1806 | /* Yield remainder of our time slice, effectively giving a | ||
| 1807 | temporary priority boost to the child process. */ | ||
| 1808 | Sleep (0); | ||
| 1809 | } | ||
| 1810 | } | ||
| 1786 | #ifdef HAVE_SOCKETS | 1811 | #ifdef HAVE_SOCKETS |
| 1787 | else if (fd_info[fd].flags & FILE_SOCKET) | 1812 | else if (fd_info[fd].flags & FILE_SOCKET) |
| 1788 | rc = pfn_recv (SOCK_HANDLE (fd), &cp->chr, sizeof (char), 0); | 1813 | rc = pfn_recv (SOCK_HANDLE (fd), &cp->chr, sizeof (char), 0); |
| @@ -1851,8 +1876,6 @@ sys_read (int fd, char * buffer, unsigned int count) | |||
| 1851 | ResetEvent (cp->char_avail); | 1876 | ResetEvent (cp->char_avail); |
| 1852 | 1877 | ||
| 1853 | case STATUS_READ_ACKNOWLEDGED: | 1878 | case STATUS_READ_ACKNOWLEDGED: |
| 1854 | /* Give process time to buffer some more output for us */ | ||
| 1855 | Sleep (50); | ||
| 1856 | break; | 1879 | break; |
| 1857 | 1880 | ||
| 1858 | default: | 1881 | default: |
| @@ -1958,6 +1981,9 @@ term_ntproc () | |||
| 1958 | #endif | 1981 | #endif |
| 1959 | } | 1982 | } |
| 1960 | 1983 | ||
| 1984 | extern BOOL can_run_dos_process; | ||
| 1985 | extern BOOL dos_process_running; | ||
| 1986 | |||
| 1961 | void | 1987 | void |
| 1962 | init_ntproc () | 1988 | init_ntproc () |
| 1963 | { | 1989 | { |
| @@ -2025,6 +2051,10 @@ init_ntproc () | |||
| 2025 | fdopen (2, "w"); | 2051 | fdopen (2, "w"); |
| 2026 | } | 2052 | } |
| 2027 | 2053 | ||
| 2054 | /* Only allow Emacs to run DOS programs on Win95. */ | ||
| 2055 | can_run_dos_process = (GetVersion () & 0x80000000); | ||
| 2056 | dos_process_running = FALSE; | ||
| 2057 | |||
| 2028 | /* unfortunately, atexit depends on implementation of malloc */ | 2058 | /* unfortunately, atexit depends on implementation of malloc */ |
| 2029 | /* atexit (term_ntproc); */ | 2059 | /* atexit (term_ntproc); */ |
| 2030 | signal (SIGABRT, term_ntproc); | 2060 | signal (SIGABRT, term_ntproc); |