* *
* 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- *
#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);
}
}
}
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;
#endif /* !NO_FD_SET */
void
-__gnat_kill (int pid, int sig)
+__gnat_kill (int pid, int sig, int close)
{
kill (pid, sig);
}
#else
void
-__gnat_kill (int pid, int sig)
+__gnat_kill (int pid, int sig, int close)
{
}
-- --
-- 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- --
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");
-- ??? 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;
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;
Signal : Integer)
is
begin
- Kill (Descriptor.Pid, Signal);
+ Kill (Descriptor.Pid, Signal, 1);
-- ??? Need to check process status here
end Send_Signal;