Not directly, but a system wide mutex can be built on top of sysv 
semaphores, files on disk, or an open tcp or unix domain socket.

As this lock would be system wide, the main consideration is to ensure that 
it is _always_ unlocked when the owning process dies for any reason. Then 
that just leaves the problem of knowing _if_ the controlling process exited 
uncleanly, is the state it was protecting now corrupted. 

On Wednesday, 5 October 2016 06:55:47 UTC+11, dc0d wrote:
>
> I had the same question tonight! On Windows (using C#) I just create a 
> Named Mutex, which is system wide. One of values that it returns identifies 
> that if the mutex is already created by other instance, or it's the first 
> time it's being created on this system.
>
> Is there something similar on Linux?
>
> On Tuesday, July 19, 2011 at 3:55:45 PM UTC+4:30, Dave Cheney wrote:
>>
>> Hi. 
>>
>> This is a glib answer, but you should check the resource that your 
>> application requires to be a singleton.
>>
>> If that is a TCP port, then exit if you cannot bind. If it's a database, 
>> then use a lock file, etc. 
>>
>> This isn't a Go specific problem. If you can give some more details, 
>> maybe someone will be able to give a more specific answer. 
>>
>> Cheers
>>
>> Dave
>>
>> Sent from my iPhone
>>
>> On 19/07/2011, at 16:56, Ruslan Mezentsev <rmib....@gmail.com> wrote:
>>
>> > Hello.
>> > How check only one instance of program is running? Use sockets,
>> > mutexes or pid files, or other?
>> > Thanks.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to