Browse Source

* Added check for existing program file. Exception is raised if it is not found

git-svn-id: trunk@5599 -
michael 18 years ago
parent
commit
bd9ee4dc83
1 changed files with 8 additions and 3 deletions
  1. 8 3
      fcl/unix/process.inc

+ 8 - 3
fcl/unix/process.inc

@@ -6,7 +6,8 @@ uses
    Unix,
    Unix,
    Baseunix;
    Baseunix;
 
 
-
+resourcestring
+  SErrNoSuchProgram = 'Executable not found: "%s"';
 
 
 Const
 Const
   PriorityConstants : Array [TProcessPriority] of Integer =
   PriorityConstants : Array [TProcessPriority] of Integer =
@@ -247,7 +248,7 @@ Var
   FEnv     : PPChar;
   FEnv     : PPChar;
   Argv     : PPChar;
   Argv     : PPChar;
   fd       : Integer;
   fd       : Integer;
-  PName    : String;
+  PName,p2    : String;
 
 
 begin
 begin
   If (poUsePipes in FProcessOptions) then
   If (poUsePipes in FProcessOptions) then
@@ -270,7 +271,11 @@ begin
             PName:=CommandLine;
             PName:=CommandLine;
           end;
           end;
         if (pos('/',PName)<>1) then
         if (pos('/',PName)<>1) then
-          PName:=FileSearch(Pname,fpgetenv('PATH'));
+          P2:=FileSearch(Pname,fpgetenv('PATH'));
+        If (P2='') then
+          Raise EProcess.CreateFmt(SErrNoSuchProgram,[PName])
+        else
+          PName:=P2;  
         Pid:=fpfork;
         Pid:=fpfork;
         if Pid<0 then
         if Pid<0 then
           Raise EProcess.Create('Failed to Fork process');
           Raise EProcess.Create('Failed to Fork process');