From b144dc2481dbe4e8281cd361d97bcde02a6db3fc Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 13 Nov 2007 19:23:34 +0000 Subject: * fix executable not found exception git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@9239 3ad0048d-3df7-0310-abae-a5850022a9f2 --- packages/fcl-process/src/unix/process.inc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'packages/fcl-process') diff --git a/packages/fcl-process/src/unix/process.inc b/packages/fcl-process/src/unix/process.inc index f88623c959..5ae60d24c1 100644 --- a/packages/fcl-process/src/unix/process.inc +++ b/packages/fcl-process/src/unix/process.inc @@ -104,9 +104,9 @@ Procedure CommandToList(S : String; List : TStrings); end; inc(wend); end; - + Result:=Copy(S,WStart,WEnd-WStart); - + if (Length(Result) > 0) and (Result[1] = Result[Length(Result)]) // if 1st char = last char and.. and (Result[1] in Literals) then // it's one of the literals, then @@ -248,6 +248,7 @@ Var FEnv : PPChar; Argv : PPChar; fd : Integer; + FoundName, PName : String; begin @@ -270,14 +271,15 @@ begin If (PName='') then PName:=CommandLine; end; - - if not FileExists(PName) then begin - PName := FileSearch(Pname,fpgetenv('PATH')); - if Length(PName) = 0 then + if not FileExists(PName) then begin + FoundName := FileSearch(Pname,fpgetenv('PATH')); + if FoundName<>'' then + PName:=FoundName + else raise EProcess.CreateFmt(SErrNoSuchProgram,[PName]); end; - + Pid:=fpfork; if Pid<0 then Raise EProcess.Create('Failed to Fork process'); @@ -302,7 +304,7 @@ begin fpdup2(HO[peWrite],1); if (poStdErrToOutPut in Options) then fpdup2(HO[peWrite],2) - else + else begin fpclose(HE[peRead]); fpdup2(HE[peWrite],2); -- cgit v1.2.1