fixes for the linux version

This commit is contained in:
Basile Burg 2015-02-07 10:26:49 +01:00
parent 0d7d51a0d8
commit a9f68c1e66
2 changed files with 26 additions and 24 deletions

View File

@ -224,7 +224,7 @@ type
(**
* Returns TRUE if EXEName is running under Windows or Linux
* Returns true if Exename is running under Windows or Linux
*)
function AppIsRunning(const ExeName: string):Boolean;
@ -865,7 +865,7 @@ begin
end;
{$IFDEF WINDOWS}
function WindowsAppIsRunning(const ExeName: string): integer;
function internalAppIsRunning(const ExeName: string): integer;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
@ -889,38 +889,37 @@ begin
CloseHandle(FSnapshotHandle);
end;
{$ENDIF}
{$IFDEF LINUX}
function LinuxAppIsRunning(const ExeName: string): integer;
function internalAppIsRunning(const ExeName: string): integer;
var
t: TProcess;
s: TStringList;
proc: TProcess;
lst: TStringList;
begin
Result := 0;
t := tprocess.Create(nil);
t.CommandLine := 'ps -C ' + ExeName;
t.Options := [poUsePipes, poWaitonexit];
proc := tprocess.Create(nil);
proc.Executable := 'ps';
proc.Parameters.Add('-C');
proc.Parameters.Add(ExeName);
proc.Options := [poUsePipes, poWaitonexit];
try
proc.Execute;
lst := TStringList.Create;
try
t.Execute;
s := TStringList.Create;
try
s.LoadFromStream(t.Output);
Result := Pos(ExeName, s.Text);
finally
s.Free;
end;
lst.LoadFromStream(proc.Output);
Result := Pos(ExeName, lst.Text);
finally
t.Free;
lst.Free;
end;
finally
proc.Free;
end;
end;
{$ENDIF}
function AppIsRunning(const ExeName: string):Boolean;
begin
{$IFDEF WINDOWS}
Result:=(WindowsAppIsRunning(ExeName) > 0);
{$ENDIF}
{$IFDEF LINUX}
Result:=(LinuxAppIsRunning(ExeName) > 0);
{$ENDIF}
Result:= internalAppIsRunning(ExeName) > 0;
end;

View File

@ -5,7 +5,10 @@ unit ce_dcd;
interface
uses
Classes, SysUtils, process, forms, strutils, windows,
Classes, SysUtils, process, forms, strutils,
{$IFDEF WINDOWS}
windows,
{$ENDIF}
ce_common, ce_writableComponent, ce_interfaces, ce_observer, ce_synmemo, ce_project;
type