summaryrefslogtreecommitdiff
path: root/gcc/ada/expect.c
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-15 13:57:56 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-15 13:57:56 +0000
commit5b91f0e70dfc5d0289f1ca6b140743763b5675a1 (patch)
treea05042bd8367388bbe2377d8298b4111af9eaae7 /gcc/ada/expect.c
parent54d2a5c93f32e49178b8abc676dcde04b48ea400 (diff)
downloadgcc-5b91f0e70dfc5d0289f1ca6b140743763b5675a1.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106974 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/expect.c')
-rw-r--r--gcc/ada/expect.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/gcc/ada/expect.c b/gcc/ada/expect.c
index 69a3364b6d3..dd03b1ca1f8 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)
{
}