[Gambas-user] Check if a program is already started
Jesus Guardon
jguardon at ...2035...
Sat Sep 12 16:20:43 CEST 2009
Just another way:
PUBLIC FUNCTION pidOf(program AS String) AS Boolean
'checks if a program is running
DIM gotpid AS String = ""
DIM running AS Boolean = FALSE
TRY SHELL "pidof " & program TO gotpid
IF gotpid THEN
running = TRUE
ELSE
running = FALSE
ENDIF
RETURN running
END
Usage:
IF pidOf("yourProgram") THEN whatever...
At least it works for me
Cheers
Jesus
Jussi Lahtinen escribió:
> Not very elegant, but works:
>
>
> Dim sOutput As String
>
> Exec ["pgrep", "-f", "-l", "NameOfYourProgram.gambas"] Wait To sOutput
>
> If Split(Trim$(sOutput), gb.NewLine).Count > 1 Then
> 'Allready running
> EndIf
>
>
> Jussi
More information about the User
mailing list