This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
When GNAT.Expect reaches the end of its input, it does not properly closes the input file descriptor, thus resulting in a memory leak. This was properly handles when calling Get_Process_Output, but not when writing the loop manually --- -- The following program had errors reported by valgrind (fd leaks) with Ada.Directories; with GNAT.Expect; with GNAT.OS_Lib; procedure GNAT_Expect is File : constant String := "/tmp/data.expect"; Count : constant := 2048; Args : GNAT.OS_Lib.Argument_List (1 .. 4); Pd : GNAT.Expect.Process_Descriptor; Match : GNAT.Expect.Expect_Match; Cmd : constant String := "echo testdata > " & File; Res : Integer := 1; begin Args (1) := new String'("-o"); Args (2) := new String'("pipefail"); Args (3) := new String'("-c"); Args (4) := new String'(Cmd); for I in 1 .. Count loop GNAT.Expect.Non_Blocking_Spawn (Descriptor => Pd, Command => "/bin/bash", Args => Args, Buffer_Size => 0); begin GNAT.Expect.Expect (Descriptor => Pd, Result => Match, Regexp => "", Timeout => -1); exception when GNAT.Expect.Process_Died => GNAT.Expect.Close (Descriptor => Pd, Status => Res); end; end loop; end GNAT_Expect; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-04-02 Emmanuel Briot <briot@adacore.com> * g-expect.adb (Expect_Internal): Fix leak of the input file descriptor.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |