aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat
diff options
context:
space:
mode:
authorDmitriy Anisimkov <anisimko@adacore.com>2021-12-21 12:01:32 +0600
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-09 09:27:28 +0000
commit9a6f7575c153e7036152002bb7b58166762592f1 (patch)
tree7797165452f29f0f3699b07c948a2dcff27a9367 /gcc/ada/libgnat
parent1e2334302d6ad5dd8526c21b8062dc16a688f3e8 (diff)
downloadgcc-9a6f7575c153e7036152002bb7b58166762592f1.zip
gcc-9a6f7575c153e7036152002bb7b58166762592f1.tar.gz
gcc-9a6f7575c153e7036152002bb7b58166762592f1.tar.bz2
[Ada] Stabilize exit code on close process
Call Kill before close input handler in Close routine. Otherwise close input handler can terminate process before Kill and exit code became unpredictable. gcc/ada/ * libgnat/g-expect.adb (Close): Call Kill before Close_Input.
Diffstat (limited to 'gcc/ada/libgnat')
-rw-r--r--gcc/ada/libgnat/g-expect.adb10
1 files changed, 4 insertions, 6 deletions
diff --git a/gcc/ada/libgnat/g-expect.adb b/gcc/ada/libgnat/g-expect.adb
index e43ef4f..1c5b831 100644
--- a/gcc/ada/libgnat/g-expect.adb
+++ b/gcc/ada/libgnat/g-expect.adb
@@ -222,6 +222,10 @@ package body GNAT.Expect is
Next_Filter : Filter_List;
begin
+ if Descriptor.Pid > 0 then -- see comment in Send_Signal
+ Kill (Descriptor.Pid, Sig_Num => 9, Close => 0);
+ end if;
+
Close_Input (Descriptor);
if Descriptor.Error_Fd /= Descriptor.Output_Fd
@@ -234,12 +238,6 @@ package body GNAT.Expect is
Close (Descriptor.Output_Fd);
end if;
- -- ??? Should have timeouts for different signals
-
- if Descriptor.Pid > 0 then -- see comment in Send_Signal
- Kill (Descriptor.Pid, Sig_Num => 9, Close => 0);
- end if;
-
GNAT.OS_Lib.Free (Descriptor.Buffer);
Descriptor.Buffer_Size := 0;