aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/expect.c29
-rw-r--r--gcc/ada/g-expect.adb14
2 files changed, 20 insertions, 23 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)
{
}
diff --git a/gcc/ada/g-expect.adb b/gcc/ada/g-expect.adb
index e94d5b6..1cb0788 100644
--- a/gcc/ada/g-expect.adb
+++ b/gcc/ada/g-expect.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2000-2005 Ada Core Technologies, Inc. --
+-- Copyright (C) 2000-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- --
@@ -89,8 +89,9 @@ package body GNAT.Expect is
procedure Dup2 (Old_Fd, New_Fd : File_Descriptor);
pragma Import (C, Dup2);
- procedure Kill (Pid : Process_Id; Sig_Num : Integer);
+ procedure Kill (Pid : Process_Id; Sig_Num : Integer; Close : Integer);
pragma Import (C, Kill, "__gnat_kill");
+ -- if Close is set to 1 all OS resources used by the Pid must be freed
function Create_Pipe (Pipe : access Pipe_Type) return Integer;
pragma Import (C, Create_Pipe, "__gnat_pipe");
@@ -221,7 +222,7 @@ package body GNAT.Expect is
-- ??? Should have timeouts for different signals
- Kill (Descriptor.Pid, 9);
+ Kill (Descriptor.Pid, 9, 0);
GNAT.OS_Lib.Free (Descriptor.Buffer);
Descriptor.Buffer_Size := 0;
@@ -339,10 +340,11 @@ package body GNAT.Expect is
return;
end if;
- -- Calculate the timeout for the next turn.
+ -- Calculate the timeout for the next turn
+
-- Note that Timeout is, from the caller's perspective, the maximum
-- time until a match, not the maximum time until some output is
- -- read, and thus can not be reused as is for Expect_Internal.
+ -- read, and thus cannot be reused as is for Expect_Internal.
if Timeout /= -1 then
Timeout_Tmp := Integer (Try_Until - Clock) * 1000;
@@ -1148,7 +1150,7 @@ package body GNAT.Expect is
Signal : Integer)
is
begin
- Kill (Descriptor.Pid, Signal);
+ Kill (Descriptor.Pid, Signal, 1);
-- ??? Need to check process status here
end Send_Signal;