mirror of https://github.com/berriedale/arun
Switch to using execvp(3) and make sure the Char_Array passed in is null-terminated
This commit is contained in:
parent
18e2f61dcf
commit
808beff643
|
@ -41,9 +41,9 @@ package body Arun.Handlers is
|
|||
|
||||
Full_Path : aliased constant String := Arun.Launcher.Find_Full_Path (Command);
|
||||
begin
|
||||
Put_Line ("Should Execute: " & Command);
|
||||
|
||||
if Full_Path /= "" then
|
||||
Put_Line ("Should Execute: " & Command);
|
||||
Arun.Launcher.Execute (Full_Path);
|
||||
end if;
|
||||
|
||||
|
|
|
@ -55,12 +55,11 @@ package body Arun.Launcher is
|
|||
use Ada.Command_Line.Environment;
|
||||
|
||||
|
||||
function Exec_And_Replace (Filename : in String;
|
||||
Arguments : in Chars_Ptr_Array;
|
||||
Env : in Chars_Ptr_Array) return Integer
|
||||
function Exec_And_Replace (Filename : in Char_Array;
|
||||
Arguments : in Chars_Ptr_Array) return Integer
|
||||
with Import,
|
||||
Convention => C,
|
||||
Link_Name => "execve";
|
||||
Link_Name => "execv";
|
||||
|
||||
procedure Print_Errno (Message : in String)
|
||||
with Import,
|
||||
|
@ -68,19 +67,13 @@ package body Arun.Launcher is
|
|||
Link_Name => "perror";
|
||||
|
||||
Default_Args : Chars_Ptr_Array (1 .. 2) := (1 => New_String (Executable_Path), 2 => Null_Ptr);
|
||||
Environment_Args : Chars_Ptr_Array (1 .. Size_T(Environment_Count + 1)) := (others => Null_Ptr);
|
||||
Status : Integer;
|
||||
begin
|
||||
-- Fierst we need to fill in our Environment_Args with the appropriate variables
|
||||
for Index in 1 .. Environment_Count loop
|
||||
Environment_Args (Size_T(Index)) := New_String (Environment_Value (Index));
|
||||
end loop;
|
||||
|
||||
Put_Line ("Spawning " & Executable_Path);
|
||||
|
||||
Status := Exec_And_Replace (Filename => Executable_Path,
|
||||
Arguments => Default_Args,
|
||||
Env => Environment_Args);
|
||||
Status := Exec_And_Replace (Filename => To_C (Item => Executable_Path,
|
||||
Append_Nul => True),
|
||||
Arguments => Default_Args);
|
||||
|
||||
-- If the Exec_And_Replace function returns then something has gone wrong
|
||||
Put_Line ("Spawned " & Executable_Path & " with " & Status'Img);
|
||||
|
|
Loading…
Reference in New Issue