summaryrefslogtreecommitdiff
path: root/gcc/ada/g-expect.adb
diff options
context:
space:
mode:
authorDoug Rupp <rupp@adacore.com>2005-02-10 14:51:58 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2005-02-10 14:51:58 +0100
commitcc892b2c9128f71cf72f4fbad94d272d02562435 (patch)
treef7ea7fe8c9dc03d190dde2da59b05740c31b5ca4 /gcc/ada/g-expect.adb
parent4e45e7a930bff7c7e6bbfa5f390a14411dc88dd7 (diff)
downloadgcc-cc892b2c9128f71cf72f4fbad94d272d02562435.tar.gz
adaint.c, [...] (to_ptr32): New function.
2005-02-09 Doug Rupp <rupp@adacore.com> Thomas Quinot <quinot@adacore.com> * adaint.c, adaint.h [VMS] (to_ptr32): New function. (MAYBE_TO_PTR32): New macro. (__gnat_portable_spawn,__gnat_portable_no_block_spawn): Adjust argv for pointer size. [VMS] (descriptor_s, ile_s): Use __char_ptr32 for adr field. [VMS] (#define fork()): Remove since unneccessary. (__gnat_set_close_on_exec): New routine to support GNAT.OS_Lib.Set_Close_On_Exec. * g-expect.adb (Set_Up_Communications): Mark the pipe descriptors for the parent side as close-on-exec so that they are not inherited by the child. * g-os_lib.ads, g-os_lib.adb (Set_Close_On_Exec): New subprogram to set or clear the FD_CLOEXEC flag on a file descriptor. From-SVN: r94811
Diffstat (limited to 'gcc/ada/g-expect.adb')
-rw-r--r--gcc/ada/g-expect.adb22
1 files changed, 21 insertions, 1 deletions
diff --git a/gcc/ada/g-expect.adb b/gcc/ada/g-expect.adb
index 144b157feee..2571a440d65 100644
--- a/gcc/ada/g-expect.adb
+++ b/gcc/ada/g-expect.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2000-2003 Ada Core Technologies, Inc. --
+-- Copyright (C) 2000-2005 Ada Core Technologies, Inc. --
-- --
-- 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- --
@@ -1123,6 +1123,8 @@ package body GNAT.Expect is
Pipe2 : access Pipe_Type;
Pipe3 : access Pipe_Type)
is
+ Status : Boolean;
+
begin
-- Create the pipes
@@ -1134,18 +1136,36 @@ package body GNAT.Expect is
return;
end if;
+ -- Record the 'parent' end of the two pipes in Pid:
+ -- Child stdin is connected to the 'write' end of Pipe1;
+ -- Child stdout is connected to the 'read' end of Pipe2.
+ -- We do not want these descriptors to remain open in the child
+ -- process, so we mark them close-on-exec/non-inheritable.
+
Pid.Input_Fd := Pipe1.Output;
+ Set_Close_On_Exec (Pipe1.Output, True, Status);
Pid.Output_Fd := Pipe2.Input;
+ Set_Close_On_Exec (Pipe2.Input, True, Status);
if Err_To_Out then
+
+ -- Reuse the standard output pipe for standard error
+
Pipe3.all := Pipe2.all;
else
+
+ -- Create a separate pipe for standard error
+
if Create_Pipe (Pipe3) /= 0 then
return;
end if;
end if;
+ -- As above, we record the proper fd for the child's
+ -- standard error stream.
+
Pid.Error_Fd := Pipe3.Input;
+ Set_Close_On_Exec (Pipe3.Input, True, Status);
end Set_Up_Communications;
----------------------------------