[Gambas-user] donot permit another instance of my program

PICCORO McKAY Lenz mckaygerhard at gmail.com
Thu May 31 15:59:39 CEST 2018


Hans, the dbus interface are not a default neither! specially if my program
its a daemon in a efficient linux and not a stupid systemd
windo-like-redhat linux

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2018-05-31 5:57 GMT-04:00 Hans Lehmann <hans at gambas-buch.de>:

> Hello,
>
> the given solutions both have a small hook. The 'pgrep' program is not
> installed by default on all systems. The variant with the look file runs
> empty if the program crashes at runtime and the created look file can no
> longer be deleted. The presented variant does not require much effort and
> works well to reliably prevent a second program start.
>
> FMain.class
>
> ' Gambas class file
>
> Public hObject As DBO ' D-Bus-Object
>
> Public Sub _new()
>
>   Dim sMessage As String
>   DBus.Unique = True
>
>   hObject = New DBO
>   Try DBus.Session.Register(hObject, "/Export1")
>   If Error Then
>      sMessage = Subst("&1 '&2' &3", ("The program"), Application.Name,
> ("has already been started!"))
>      Message.Warning(sMessage)
>      Me.Close()
>   Endif
>
> End
>
> Public Sub Form_Open()
>   FMain.Resizable = False
> End
>
> Public Sub Form_Close()
>   If DBus.IsRegistered(hObject) Then DBus.Session.Unregister(hObject)
>   Me.Close()
> End
>
> ------------------------------
>
> DBO.class
>
> ' Gambas class file
>
> Inherits DBusObject
> Create Static
>
> ' The class can remain empty from here on...
>
> ------------------------------
>
>
>
> With kind regards
>
> Hans
> www.gambas-book.net
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180531/e16bc72d/attachment.html>


More information about the User mailing list