diff options
author | Pascal Obry <obry@adacore.com> | 2005-11-15 14:57:56 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2005-11-15 14:57:56 +0100 |
commit | 379ecbfacf3272e1c12b5ac930155ea6f5367a71 (patch) | |
tree | a05042bd8367388bbe2377d8298b4111af9eaae7 /gcc/ada/expect.c | |
parent | 6ce0c3f5ed442fe46a2ba21de5a437704791dae5 (diff) | |
download | gcc-379ecbfacf3272e1c12b5ac930155ea6f5367a71.zip gcc-379ecbfacf3272e1c12b5ac930155ea6f5367a71.tar.gz gcc-379ecbfacf3272e1c12b5ac930155ea6f5367a71.tar.bz2 |
expect.c (__gnat_kill): Fix implementation...
2005-11-14 Pascal Obry <obry@adacore.com>
* expect.c (__gnat_kill) [Win32]: Fix implementation, the pid returned
by spawnve is a process handle, no need to convert. Add a parameter
close to control wether the process handle must be closed.
(__gnat_waitpid): Fix implementation, the pid returned by spawnve is
a process handle, not need to convert.
(__gnat_kill) [*]: Add dummy parameter close to match the Win32 spec.
* g-expect.adb: (Kill): Document the new close parameter.
(Close): Do not release the process handle in the kill there as
waitpid() is using it.
(Send_Signal): Release the process handle.
From-SVN: r106974
Diffstat (limited to 'gcc/ada/expect.c')
-rw-r--r-- | gcc/ada/expect.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/gcc/ada/expect.c b/gcc/ada/expect.c index 69a3364..dd03b1c 100644 --- a/gcc/ada/expect.c +++ b/gcc/ada/expect.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 2001-2005 Ada Core Technologies, Inc. * + * Copyright (C) 2001-2005, AdaCore * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -76,17 +76,15 @@ #include <process.h> void -__gnat_kill (int pid, int sig) +__gnat_kill (int pid, int sig, int close) { - HANDLE process_handle; - if (sig == 9) { - process_handle = OpenProcess (PROCESS_TERMINATE, FALSE, pid); - if (process_handle != NULL) + if ((HANDLE)pid != NULL) { - TerminateProcess (process_handle, 0); - CloseHandle (process_handle); + TerminateProcess ((HANDLE)pid, 0); + if (close) + CloseHandle ((HANDLE)pid); } } } @@ -94,17 +92,14 @@ __gnat_kill (int pid, int sig) int __gnat_waitpid (int pid) { - HANDLE process_handle; DWORD exitcode = 1; DWORD res; - process_handle = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, pid); - - if (process_handle != NULL) + if ((HANDLE)pid != NULL) { - res = WaitForSingleObject (process_handle, INFINITE); - GetExitCodeProcess (process_handle, &exitcode); - CloseHandle (process_handle); + res = WaitForSingleObject ((HANDLE)pid, INFINITE); + GetExitCodeProcess ((HANDLE)pid, &exitcode); + CloseHandle ((HANDLE)pid); } return (int) exitcode; @@ -337,7 +332,7 @@ typedef long fd_mask; #endif /* !NO_FD_SET */ void -__gnat_kill (int pid, int sig) +__gnat_kill (int pid, int sig, int close) { kill (pid, sig); } @@ -456,7 +451,7 @@ __gnat_expect_poll (int *fd, int num_fd, int timeout, int *is_set) #else void -__gnat_kill (int pid, int sig) +__gnat_kill (int pid, int sig, int close) { } |