[Gambas-user] Single instance application, anyone else done it?

Tobias Boege tobs at taboege.de
Thu Jul 8 16:59:05 CEST 2021

On Thu, 08 Jul 2021, John Dovey wrote:
> Just to throw a spammer in the works, what about those of us who run
> everything throw X windows and don’t have a desktop at all?

D-Bus does not need a desktop either, it is a message passing mechanism.
For example, systemd depends on D-Bus, so many systems without a desktop
or even without a graphical display at all might already run D-Bus.

If you don't want to rely on the presence of D-Bus, there is still the
"pid file" technique (but you have to handle stale pid files). Or you
could make your program set up a UNIX socket in a well-known location.
Other instances of your program will try to connect to the socket and
if they get a response, another instance is running. If not, they
create that socket and answer on it to prove that they're running.


"There's an old saying: Don't change anything... ever!" -- Mr. Monk

More information about the User mailing list