you can use GtkApplication , which by default provides support for one instance.
if you cannot use GtkApplication , then you can use libunique (which has deprecated GtkApplication , but works fine with GTK + 2.x and GTK + 3.x): https://wiki.gnome.org/LibUnique
you can implement the same system that is used by both GtkApplication and libunique , which is based on DBus: you must acquire a known name for your application in the first instance, and if something is already running this famous name means that the instance is already running , then exit the application.
source share