From: Dmitriy Anisimkov Date: Tue, 21 Dec 2021 06:01:32 +0000 (+0600) Subject: [Ada] Stabilize exit code on close process X-Git-Tag: basepoints/gcc-14~7034 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a6f7575c153e7036152002bb7b58166762592f1;p=thirdparty%2Fgcc.git [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. --- diff --git a/gcc/ada/libgnat/g-expect.adb b/gcc/ada/libgnat/g-expect.adb index e43ef4f352d..1c5b8312d7c 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;