[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/w32proc.c
From: |
Juanma Barranquero |
Subject: |
[Emacs-diffs] Changes to emacs/src/w32proc.c |
Date: |
Tue, 04 Feb 2003 09:03:50 -0500 |
Index: emacs/src/w32proc.c
diff -c emacs/src/w32proc.c:1.54 emacs/src/w32proc.c:1.55
*** emacs/src/w32proc.c:1.54 Tue Jul 30 12:24:30 2002
--- emacs/src/w32proc.c Tue Feb 4 09:03:15 2003
***************
*** 120,130 ****
static signal_handler sig_handlers[NSIG];
/* Fake signal implementation to record the SIGCHLD handler. */
! signal_handler
sys_signal (int sig, signal_handler handler)
{
signal_handler old;
!
if (sig != SIGCHLD)
{
errno = EINVAL;
--- 120,130 ----
static signal_handler sig_handlers[NSIG];
/* Fake signal implementation to record the SIGCHLD handler. */
! signal_handler
sys_signal (int sig, signal_handler handler)
{
signal_handler old;
!
if (sig != SIGCHLD)
{
errno = EINVAL;
***************
*** 151,157 ****
{
child_process *cp;
DWORD id;
!
for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--)
if (!CHILD_ACTIVE (cp))
goto Initialise;
--- 151,157 ----
{
child_process *cp;
DWORD id;
!
for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--)
if (!CHILD_ACTIVE (cp))
goto Initialise;
***************
*** 182,188 ****
return NULL;
}
! void
delete_child (child_process *cp)
{
int i;
--- 182,188 ----
return NULL;
}
! void
delete_child (child_process *cp)
{
int i;
***************
*** 257,270 ****
is normally blocked until woken by select() to check for input by
reading one char. When the read completes, char_avail is signalled
to wake up the select emulator and the thread blocks itself again. */
! DWORD WINAPI
reader_thread (void *arg)
{
child_process *cp;
!
/* Our identity */
cp = (child_process *)arg;
!
/* We have to wait for the go-ahead before we can start */
if (cp == NULL
|| WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
--- 257,270 ----
is normally blocked until woken by select() to check for input by
reading one char. When the read completes, char_avail is signalled
to wake up the select emulator and the thread blocks itself again. */
! DWORD WINAPI
reader_thread (void *arg)
{
child_process *cp;
!
/* Our identity */
cp = (child_process *)arg;
!
/* We have to wait for the go-ahead before we can start */
if (cp == NULL
|| WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
***************
*** 287,297 ****
if (rc == STATUS_READ_ERROR)
return 1;
!
/* If the read died, the child has died so let the thread die */
if (rc == STATUS_READ_FAILED)
break;
!
/* Wait until our input is acknowledged before reading again */
if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
{
--- 287,297 ----
if (rc == STATUS_READ_ERROR)
return 1;
!
/* If the read died, the child has died so let the thread die */
if (rc == STATUS_READ_FAILED)
break;
!
/* Wait until our input is acknowledged before reading again */
if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
{
***************
*** 308,314 ****
sys_spawnve, and is not generally valid at any other time. */
static char * process_dir;
! static BOOL
create_child (char *exe, char *cmdline, char *env, int is_gui_app,
int * pPid, child_process *cp)
{
--- 308,314 ----
sys_spawnve, and is not generally valid at any other time. */
static char * process_dir;
! static BOOL
create_child (char *exe, char *cmdline, char *env, int is_gui_app,
int * pPid, child_process *cp)
{
***************
*** 319,330 ****
#endif
DWORD flags;
char dir[ MAXPATHLEN ];
!
if (cp == NULL) abort ();
!
memset (&start, 0, sizeof (start));
start.cb = sizeof (start);
!
#ifdef HAVE_NTGUI
if (NILP (Vw32_start_process_show_window) && !is_gui_app)
start.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
--- 319,330 ----
#endif
DWORD flags;
char dir[ MAXPATHLEN ];
!
if (cp == NULL) abort ();
!
memset (&start, 0, sizeof (start));
start.cb = sizeof (start);
!
#ifdef HAVE_NTGUI
if (NILP (Vw32_start_process_show_window) && !is_gui_app)
start.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
***************
*** 347,353 ****
sec_attrs.nLength = sizeof (sec_attrs);
sec_attrs.lpSecurityDescriptor = NULL /* &sec_desc */;
sec_attrs.bInheritHandle = FALSE;
!
strcpy (dir, process_dir);
unixtodos_filename (dir);
--- 347,353 ----
sec_attrs.nLength = sizeof (sec_attrs);
sec_attrs.lpSecurityDescriptor = NULL /* &sec_desc */;
sec_attrs.bInheritHandle = FALSE;
!
strcpy (dir, process_dir);
unixtodos_filename (dir);
***************
*** 383,404 ****
to register the handle with the process
This way the select emulator knows how to match file handles with
entries in child_procs. */
! void
register_child (int pid, int fd)
{
child_process *cp;
!
cp = find_child_pid (pid);
if (cp == NULL)
{
DebPrint (("register_child unable to find pid %lu\n", pid));
return;
}
!
#ifdef FULL_DEBUG
DebPrint (("register_child registered fd %d with pid %lu\n", fd, pid));
#endif
!
cp->fd = fd;
/* thread is initially blocked until select is called; set status so
--- 383,404 ----
to register the handle with the process
This way the select emulator knows how to match file handles with
entries in child_procs. */
! void
register_child (int pid, int fd)
{
child_process *cp;
!
cp = find_child_pid (pid);
if (cp == NULL)
{
DebPrint (("register_child unable to find pid %lu\n", pid));
return;
}
!
#ifdef FULL_DEBUG
DebPrint (("register_child registered fd %d with pid %lu\n", fd, pid));
#endif
!
cp->fd = fd;
/* thread is initially blocked until select is called; set status so
***************
*** 419,425 ****
signal failure to the select emulator.
The select emulator then calls this routine to clean up.
Since the thread signaled failure we can assume it is exiting. */
! static void
reap_subprocess (child_process *cp)
{
if (cp->procinfo.hProcess)
--- 419,425 ----
signal failure to the select emulator.
The select emulator then calls this routine to clean up.
Since the thread signaled failure we can assume it is exiting. */
! static void
reap_subprocess (child_process *cp)
{
if (cp->procinfo.hProcess)
***************
*** 448,454 ****
When it does, close its handle
Return the pid and fill in the status if non-NULL. */
! int
sys_wait (int *status)
{
DWORD active, retval;
--- 448,454 ----
When it does, close its handle
Return the pid and fill in the status if non-NULL. */
! int
sys_wait (int *status)
{
DWORD active, retval;
***************
*** 456,462 ****
int pid;
child_process *cp, *cps[MAX_CHILDREN];
HANDLE wait_hnd[MAX_CHILDREN];
!
nh = 0;
if (dead_child != NULL)
{
--- 456,462 ----
int pid;
child_process *cp, *cps[MAX_CHILDREN];
HANDLE wait_hnd[MAX_CHILDREN];
!
nh = 0;
if (dead_child != NULL)
{
***************
*** 479,485 ****
nh++;
}
}
!
if (nh == 0)
{
/* Nothing to wait on, so fail */
--- 479,485 ----
nh++;
}
}
!
if (nh == 0)
{
/* Nothing to wait on, so fail */
***************
*** 535,541 ****
retval = SIGINT;
else
retval <<= 8;
!
cp = cps[active];
pid = cp->pid;
#ifdef FULL_DEBUG
--- 535,541 ----
retval = SIGINT;
else
retval <<= 8;
!
cp = cps[active];
pid = cp->pid;
#ifdef FULL_DEBUG
***************
*** 571,577 ****
}
reap_subprocess (cp);
!
return pid;
}
--- 571,577 ----
}
reap_subprocess (cp);
!
return pid;
}
***************
*** 580,586 ****
{
file_data executable;
char * p;
!
/* Default values in case we can't tell for sure. */
*is_dos_app = FALSE;
*is_cygnus_app = FALSE;
--- 580,586 ----
{
file_data executable;
char * p;
!
/* Default values in case we can't tell for sure. */
*is_dos_app = FALSE;
*is_cygnus_app = FALSE;
***************
*** 590,596 ****
return;
p = strrchr (filename, '.');
!
/* We can only identify DOS .com programs from the extension. */
if (p && stricmp (p, ".com") == 0)
*is_dos_app = TRUE;
--- 590,596 ----
return;
p = strrchr (filename, '.');
!
/* We can only identify DOS .com programs from the extension. */
if (p && stricmp (p, ".com") == 0)
*is_dos_app = TRUE;
***************
*** 623,633 ****
nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header +
dos_header->e_lfanew);
! if ((char *) nt_header > (char *) dos_header + executable.size)
{
/* Some dos headers (pkunzip) have bogus e_lfanew fields. */
*is_dos_app = TRUE;
! }
else if (nt_header->Signature != IMAGE_NT_SIGNATURE
&& LOWORD (nt_header->Signature) != IMAGE_OS2_SIGNATURE)
{
--- 623,633 ----
nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header +
dos_header->e_lfanew);
! if ((char *) nt_header > (char *) dos_header + executable.size)
{
/* Some dos headers (pkunzip) have bogus e_lfanew fields. */
*is_dos_app = TRUE;
! }
else if (nt_header->Signature != IMAGE_NT_SIGNATURE
&& LOWORD (nt_header->Signature) != IMAGE_OS2_SIGNATURE)
{
***************
*** 664,670 ****
*is_gui_app = (nt_header->OptionalHeader.Subsystem ==
IMAGE_SUBSYSTEM_WINDOWS_GUI);
}
}
!
unwind:
close_file_data (&executable);
}
--- 664,670 ----
*is_gui_app = (nt_header->OptionalHeader.Subsystem ==
IMAGE_SUBSYSTEM_WINDOWS_GUI);
}
}
!
unwind:
close_file_data (&executable);
}
***************
*** 717,723 ****
/* When a new child process is created we need to register it in our list,
so intercept spawn requests. */
! int
sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
{
Lisp_Object program, full;
--- 717,723 ----
/* When a new child process is created we need to register it in our list,
so intercept spawn requests. */
! int
sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
{
Lisp_Object program, full;
***************
*** 746,752 ****
if (NILP (Ffile_executable_p (program)))
{
struct gcpro gcpro1;
!
full = Qnil;
GCPRO1 (program);
openp (Vexec_path, program, Vexec_suffixes, &full, make_number (X_OK));
--- 746,752 ----
if (NILP (Ffile_executable_p (program)))
{
struct gcpro gcpro1;
!
full = Qnil;
GCPRO1 (program);
openp (Vexec_path, program, Vexec_suffixes, &full, make_number (X_OK));
***************
*** 789,795 ****
}
unixtodos_filename (cmdname);
}
!
/* we have to do some conjuring here to put argv and envp into the
form CreateProcess wants... argv needs to be a space separated/null
terminated list of parameters, and envp is a null
--- 789,795 ----
}
unixtodos_filename (cmdname);
}
!
/* we have to do some conjuring here to put argv and envp into the
form CreateProcess wants... argv needs to be a space separated/null
terminated list of parameters, and envp is a null
***************
*** 830,837 ****
else
escape_char = is_cygnus_app ? '"' : '\\';
}
!
! /* Cygwin apps needs quoting a bit more often */
if (escape_char == '"')
sepchars = "\r\n\t\f '";
--- 830,837 ----
else
escape_char = is_cygnus_app ? '"' : '\\';
}
!
! /* Cygwin apps needs quoting a bit more often */
if (escape_char == '"')
sepchars = "\r\n\t\f '";
***************
*** 966,972 ****
targ++;
}
*--parg = '\0';
!
/* and envp... */
arglen = 1;
targ = envp;
--- 966,972 ----
targ++;
}
*--parg = '\0';
!
/* and envp... */
arglen = 1;
targ = envp;
***************
*** 977,983 ****
numenv++;
}
/* extra env vars... */
! sprintf (ppid_env_var_buffer, "EM_PARENT_PROCESS_ID=%d",
GetCurrentProcessId ());
arglen += strlen (ppid_env_var_buffer) + 1;
numenv++;
--- 977,983 ----
numenv++;
}
/* extra env vars... */
! sprintf (ppid_env_var_buffer, "EM_PARENT_PROCESS_ID=%d",
GetCurrentProcessId ());
arglen += strlen (ppid_env_var_buffer) + 1;
numenv++;
***************
*** 1004,1010 ****
errno = EAGAIN;
return -1;
}
!
/* Now create the process. */
if (!create_child (cmdname, cmdline, env, is_gui_app, &pid, cp))
{
--- 1004,1010 ----
errno = EAGAIN;
return -1;
}
!
/* Now create the process. */
if (!create_child (cmdname, cmdline, env, is_gui_app, &pid, cp))
{
***************
*** 1012,1018 ****
errno = ENOEXEC;
return -1;
}
!
return pid;
}
--- 1012,1018 ----
errno = ENOEXEC;
return -1;
}
!
return pid;
}
***************
*** 1043,1049 ****
/* From process.c */
extern int proc_buffered_char[];
! int
sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
EMACS_TIME *timeout)
{
--- 1043,1049 ----
/* From process.c */
extern int proc_buffered_char[];
! int
sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
EMACS_TIME *timeout)
{
***************
*** 1054,1064 ****
child_process *cp, *cps[MAX_CHILDREN];
HANDLE wait_hnd[MAXDESC + MAX_CHILDREN];
int fdindex[MAXDESC]; /* mapping from wait handles back to descriptors */
!
timeout_ms = timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) :
INFINITE;
/* If the descriptor sets are NULL but timeout isn't, then just Sleep. */
! if (rfds == NULL && wfds == NULL && efds == NULL && timeout != NULL)
{
Sleep (timeout_ms);
return 0;
--- 1054,1064 ----
child_process *cp, *cps[MAX_CHILDREN];
HANDLE wait_hnd[MAXDESC + MAX_CHILDREN];
int fdindex[MAXDESC]; /* mapping from wait handles back to descriptors */
!
timeout_ms = timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) :
INFINITE;
/* If the descriptor sets are NULL but timeout isn't, then just Sleep. */
! if (rfds == NULL && wfds == NULL && efds == NULL && timeout != NULL)
{
Sleep (timeout_ms);
return 0;
***************
*** 1070,1076 ****
errno = EINVAL;
return -1;
}
!
orfds = *rfds;
FD_ZERO (rfds);
nr = 0;
--- 1070,1076 ----
errno = EINVAL;
return -1;
}
!
orfds = *rfds;
FD_ZERO (rfds);
nr = 0;
***************
*** 1078,1084 ****
/* Always wait on interrupt_handle, to detect C-g (quit). */
wait_hnd[0] = interrupt_handle;
fdindex[0] = -1;
!
/* Build a list of pipe handles to wait on. */
nh = 1;
for (i = 0; i < nfds; i++)
--- 1078,1084 ----
/* Always wait on interrupt_handle, to detect C-g (quit). */
wait_hnd[0] = interrupt_handle;
fdindex[0] = -1;
!
/* Build a list of pipe handles to wait on. */
nh = 1;
for (i = 0; i < nfds; i++)
***************
*** 1195,1209 ****
cps[nc] = cp;
nc++;
}
!
/* Nothing to look for, so we didn't find anything */
! if (nh + nc == 0)
{
if (timeout)
Sleep (timeout_ms);
return 0;
}
!
start_time = GetTickCount ();
/* Wait for input or child death to be signalled. If user input is
--- 1195,1209 ----
cps[nc] = cp;
nc++;
}
!
/* Nothing to look for, so we didn't find anything */
! if (nh + nc == 0)
{
if (timeout)
Sleep (timeout_ms);
return 0;
}
!
start_time = GetTickCount ();
/* Wait for input or child death to be signalled. If user input is
***************
*** 1362,1375 ****
return TRUE;
}
! int
sys_kill (int pid, int sig)
{
child_process *cp;
HANDLE proc_hand;
int need_to_free = 0;
int rc = 0;
!
/* Only handle signals that will result in the process dying */
if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
{
--- 1362,1375 ----
return TRUE;
}
! int
sys_kill (int pid, int sig)
{
child_process *cp;
HANDLE proc_hand;
int need_to_free = 0;
int rc = 0;
!
/* Only handle signals that will result in the process dying */
if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
{
***************
*** 1396,1402 ****
/* Try to locate console window for process. */
EnumWindows (find_child_console, (LPARAM) cp);
}
!
if (sig == SIGINT || sig == SIGQUIT)
{
if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd)
--- 1396,1402 ----
/* Try to locate console window for process. */
EnumWindows (find_child_console, (LPARAM) cp);
}
!
if (sig == SIGINT || sig == SIGQUIT)
{
if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd)
***************
*** 1572,1586 ****
handles[2] = GetStdHandle (STD_ERROR_HANDLE);
/* make inheritable copies of the new handles */
! if (!DuplicateHandle (parent,
(HANDLE) _get_osfhandle (in),
parent,
! &newstdin,
! 0,
! TRUE,
DUPLICATE_SAME_ACCESS))
report_file_error ("Duplicating input handle for child", Qnil);
!
if (!DuplicateHandle (parent,
(HANDLE) _get_osfhandle (out),
parent,
--- 1572,1586 ----
handles[2] = GetStdHandle (STD_ERROR_HANDLE);
/* make inheritable copies of the new handles */
! if (!DuplicateHandle (parent,
(HANDLE) _get_osfhandle (in),
parent,
! &newstdin,
! 0,
! TRUE,
DUPLICATE_SAME_ACCESS))
report_file_error ("Duplicating input handle for child", Qnil);
!
if (!DuplicateHandle (parent,
(HANDLE) _get_osfhandle (out),
parent,
***************
*** 1589,1595 ****
TRUE,
DUPLICATE_SAME_ACCESS))
report_file_error ("Duplicating output handle for child", Qnil);
!
if (!DuplicateHandle (parent,
(HANDLE) _get_osfhandle (err),
parent,
--- 1589,1595 ----
TRUE,
DUPLICATE_SAME_ACCESS))
report_file_error ("Duplicating output handle for child", Qnil);
!
if (!DuplicateHandle (parent,
(HANDLE) _get_osfhandle (err),
parent,
***************
*** 1602,1608 ****
/* and store them as our std handles */
if (!SetStdHandle (STD_INPUT_HANDLE, newstdin))
report_file_error ("Changing stdin handle", Qnil);
!
if (!SetStdHandle (STD_OUTPUT_HANDLE, newstdout))
report_file_error ("Changing stdout handle", Qnil);
--- 1602,1608 ----
/* and store them as our std handles */
if (!SetStdHandle (STD_INPUT_HANDLE, newstdin))
report_file_error ("Changing stdin handle", Qnil);
!
if (!SetStdHandle (STD_OUTPUT_HANDLE, newstdout))
report_file_error ("Changing stdout handle", Qnil);
***************
*** 1933,1939 ****
return make_number (GetUserDefaultLCID ());
}
!
DEFUN ("w32-set-current-locale", Fw32_set_current_locale,
Sw32_set_current_locale, 1, 1, 0,
doc: /* Make Windows locale LCID be the current locale setting for
Emacs.
If successful, the new locale id is returned, otherwise nil. */)
--- 1933,1939 ----
return make_number (GetUserDefaultLCID ());
}
!
DEFUN ("w32-set-current-locale", Fw32_set_current_locale,
Sw32_set_current_locale, 1, 1, 0,
doc: /* Make Windows locale LCID be the current locale setting for
Emacs.
If successful, the new locale id is returned, otherwise nil. */)
***************
*** 1990,1996 ****
return make_number (GetConsoleCP ());
}
!
DEFUN ("w32-set-console-codepage", Fw32_set_console_codepage,
Sw32_set_console_codepage, 1, 1, 0,
doc: /* Make Windows codepage CP be the current codepage setting for
Emacs.
--- 1990,1996 ----
return make_number (GetConsoleCP ());
}
!
DEFUN ("w32-set-console-codepage", Fw32_set_console_codepage,
Sw32_set_console_codepage, 1, 1, 0,
doc: /* Make Windows codepage CP be the current codepage setting for
Emacs.
***************
*** 2019,2025 ****
return make_number (GetConsoleOutputCP ());
}
!
DEFUN ("w32-set-console-output-codepage", Fw32_set_console_output_codepage,
Sw32_set_console_output_codepage, 1, 1, 0,
doc: /* Make Windows codepage CP be the current codepage setting for
Emacs.
--- 2019,2025 ----
return make_number (GetConsoleOutputCP ());
}
!
DEFUN ("w32-set-console-output-codepage", Fw32_set_console_output_codepage,
Sw32_set_console_output_codepage, 1, 1, 0,
doc: /* Make Windows codepage CP be the current codepage setting for
Emacs.
***************
*** 2099,2105 ****
make_number ((kl >> 16) & 0xffff));
}
!
DEFUN ("w32-set-keyboard-layout", Fw32_set_keyboard_layout,
Sw32_set_keyboard_layout, 1, 1, 0,
doc: /* Make LAYOUT be the current keyboard layout for Emacs.
--- 2099,2105 ----
make_number ((kl >> 16) & 0xffff));
}
!
DEFUN ("w32-set-keyboard-layout", Fw32_set_keyboard_layout,
Sw32_set_keyboard_layout, 1, 1, 0,
doc: /* Make LAYOUT be the current keyboard layout for Emacs.
***************
*** 2218,2224 ****
This applies when performing completions and file name expansion.
Note that the value of this setting also affects remote file names,
so you probably don't want to set to non-nil if you use case-sensitive
! filesystems via ange-ftp. */);
Vw32_downcase_file_names = Qnil;
#if 0
--- 2218,2224 ----
This applies when performing completions and file name expansion.
Note that the value of this setting also affects remote file names,
so you probably don't want to set to non-nil if you use case-sensitive
! filesystems via ange-ftp. */);
Vw32_downcase_file_names = Qnil;
#if 0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/src/w32proc.c,
Juanma Barranquero <=