X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Fprocess-nt.c;h=0582761e01a58e8c15b294b8c7c6b75debd81ad1;hp=4435a2532d93f801f18ee89166372d3af136161f;hb=976b002b16336930724ae22476014583ad022e7d;hpb=6883ee56ec887c2c48abe5b06b5e66aa74031910 diff --git a/src/process-nt.c b/src/process-nt.c index 4435a25..0582761 100644 --- a/src/process-nt.c +++ b/src/process-nt.c @@ -1,4 +1,4 @@ -/* Asynchronous subprocess implemenation for Win32 +/* Asynchronous subprocess implementation for Win32 Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. Copyright (C) 1995 Sun Microsystems, Inc. @@ -33,16 +33,23 @@ Boston, MA 02111-1307, USA. */ #include "sysdep.h" #include +#ifndef __MINGW32__ #include +#else +#include +#endif #include #ifdef HAVE_SOCKETS #include #endif +/* Arbitrary size limit for code fragments passed to run_in_other_process */ +#define FRAGMENT_CODE_SIZE 32 + /* Bound by winnt.el */ Lisp_Object Qnt_quote_process_args; -/* Implemenation-specific data. Pointed to by Lisp_Process->process_data */ +/* Implementation-specific data. Pointed to by Lisp_Process->process_data */ struct nt_process_data { HANDLE h_process; @@ -143,8 +150,8 @@ free_process_memory (process_memory* pmc) /* * Run ROUTINE in the context of process determined by H_PROCESS. The - * routine is passed the address of DATA as parameter. CODE_END is the - * address immediately after ROUTINE's code. DATA_SIZE is the size of + * routine is passed the address of DATA as parameter. The ROUTINE must + * not be longer than ROUTINE_CODE_SIZE bytes. DATA_SIZE is the size of * DATA structure. * * Note that the code must be positionally independent, and compiled @@ -157,11 +164,11 @@ free_process_memory (process_memory* pmc) */ static DWORD run_in_other_process (HANDLE h_process, - LPTHREAD_START_ROUTINE routine, LPVOID code_end, + LPTHREAD_START_ROUTINE routine, LPVOID data, size_t data_size) { process_memory pm; - size_t code_size = (LPBYTE)code_end - (LPBYTE)routine; + CONST size_t code_size = FRAGMENT_CODE_SIZE; /* Need at most 3 extra bytes of memory, for data alignment */ size_t total_size = code_size + data_size + 3; LPVOID remote_data; @@ -223,6 +230,11 @@ run_in_other_process (HANDLE h_process, * SIGKILL, SIGTERM, SIGQUIT, SIGHUP - These four translate to ExitProcess * executed by the remote process * SIGINT - The remote process is sent CTRL_BREAK_EVENT + * + * The MSVC5.0 compiler feels free to re-order functions within a + * compilation unit, so we have no way of finding out the size of the + * following functions. Therefore these functions must not be larger than + * FRAGMENT_CODE_SIZE. */ /* @@ -240,12 +252,6 @@ sigkill_proc (sigkill_data* data) return 1; } -/* Watermark in code space */ -static void -sigkill_code_end (void) -{ -} - /* * Sending break or control c */ @@ -261,12 +267,6 @@ sigint_proc (sigint_data* data) return (*data->adr_GenerateConsoleCtrlEvent) (data->event, 0); } -/* Watermark in code space */ -static void -sigint_code_end (void) -{ -} - /* * Enabling signals */ @@ -282,12 +282,6 @@ sig_enable_proc (sig_enable_data* data) return 1; } -/* Watermark in code space */ -static void -sig_enable_code_end (void) -{ -} - /* * Send signal SIGNO to process H_PROCESS. * Return nonzero if successful. @@ -316,8 +310,8 @@ send_signal (HANDLE h_process, int signo) sigkill_data d; d.adr_ExitProcess = GetProcAddress (h_kernel, "ExitProcess"); assert (d.adr_ExitProcess); - retval = run_in_other_process (h_process, - sigkill_proc, sigkill_code_end, + retval = run_in_other_process (h_process, + (LPTHREAD_START_ROUTINE)sigkill_proc, &d, sizeof (d)); break; } @@ -328,8 +322,8 @@ send_signal (HANDLE h_process, int signo) GetProcAddress (h_kernel, "GenerateConsoleCtrlEvent"); assert (d.adr_GenerateConsoleCtrlEvent); d.event = CTRL_C_EVENT; - retval = run_in_other_process (h_process, - sigint_proc, sigint_code_end, + retval = run_in_other_process (h_process, + (LPTHREAD_START_ROUTINE)sigint_proc, &d, sizeof (d)); break; } @@ -353,8 +347,7 @@ enable_child_signals (HANDLE h_process) d.adr_SetConsoleCtrlHandler = GetProcAddress (h_kernel, "SetConsoleCtrlHandler"); assert (d.adr_SetConsoleCtrlHandler); - run_in_other_process (h_process, - sig_enable_proc, sig_enable_code_end, + run_in_other_process (h_process, (LPTHREAD_START_ROUTINE)sig_enable_proc, &d, sizeof (d)); } @@ -395,7 +388,7 @@ nt_finalize_process_data (struct Lisp_Process *p, int for_disksave) } /* - * Initialize XEmacs process implemenation once + * Initialize XEmacs process implementation once */ static void nt_init_process (void) @@ -411,7 +404,7 @@ nt_init_process (void) * object. If this function signals, the caller is responsible for * deleting (and finalizing) the process object. * - * The method must return PID of the new proces, a (positive??? ####) number + * The method must return PID of the new process, a (positive??? ####) number * which fits into Lisp_Int. No return value indicates an error, the method * must signal an error instead. */ @@ -620,7 +613,7 @@ nt_update_status_if_terminated (struct Lisp_Process* p) } /* - * Stuff the entire contents of LSTREAM to the process ouptut pipe + * Stuff the entire contents of LSTREAM to the process output pipe */ /* #### If only this function could be somehow merged with @@ -634,14 +627,14 @@ nt_send_process (Lisp_Object proc, struct lstream* lstream) /* use a reasonable-sized buffer (somewhere around the size of the stream buffer) so as to avoid inundating the stream with blocked data. */ - Bufbyte chunkbuf[512]; + Bufbyte chunkbuf[128]; Bytecount chunklen; while (1) { int writeret; - chunklen = Lstream_read (lstream, chunkbuf, 512); + chunklen = Lstream_read (lstream, chunkbuf, 128); if (chunklen <= 0) break; /* perhaps should abort() if < 0? This should never happen. */ @@ -875,7 +868,7 @@ nt_open_network_stream (Lisp_Object name, Lisp_Object host, Lisp_Object service, /* We don't want to be blocked on connect */ { - unsigned int nonblock = 1; + unsigned long nonblock = 1; ioctlsocket (s, FIONBIO, &nonblock); } @@ -906,7 +899,7 @@ nt_open_network_stream (Lisp_Object name, Lisp_Object host, Lisp_Object service, if (nsel > 0) { - /* Check was connnection successful or not */ + /* Check: was connection successful or not? */ tv.tv_usec = 0; nsel = select (0, NULL, NULL, &fdset, &tv); if (nsel > 0)