Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-02-2005, 02:54 PM   #1
LQ Newbie
Registered: Feb 2005
Posts: 5

Rep: Reputation: 0
Cool Named mutex in Linux

Does the pthread library support the idea of a named mutex? I want to use a named mutex to prevent multiple binary execution.
Old 03-02-2005, 02:59 PM   #2
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
You could use SysV semaphores. (see semget() and friends) The more traditional way is to just use a lock file you create with open()'s O_CREAT|O_EXCL flags. Of course with either one you need to be careful about cleaning it up in response to any signals you might get.

The lock file has the advantage that an average user has a better idea of how to get rid of it. Nobody knows what to do with ipcrm.

A lazier way would be to dig around in /proc or the output of ps. That way you dont have to worry about cleanup, but you do have to worry about false positives depending on how carefully you parse it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best browser for linux, what is it named? TruongAn General 3 11-24-2005 08:41 AM
cannot find named.conf and /var/named kaushikma Red Hat 1 02-07-2004 12:49 PM
Linux named domain redirects? Nic-MDKman General 2 02-04-2004 09:42 AM
Virtual Host type, named or IP via SSL? Named VH is not possible? piratebiter Linux - Security 3 08-20-2003 05:27 PM
mutex equivalent in Linux devershetty Linux - Newbie 1 07-24-2003 10:02 PM

All times are GMT -5. The time now is 08:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration