Talk:Determine if only one instance is running: Difference between revisions

→‎C Solution: OpenBSD is broken; "/", SEM_FAILED.
(C Solution)
(→‎C Solution: OpenBSD is broken; "/", SEM_FAILED.)
Line 8:
 
[[User:Markhobley|Markhobley]] 06:56, 3 April 2011 (UTC)
 
: I run [[OpenBSD]]. This system has [http://www.openbsd.org/cgi-bin/man.cgi?query=sem_open&apropos=0&sektion=3&manpath=OpenBSD+Current&arch=i386&format=html a very broken ''sem_open()''] which always fails with ENOSYS. I changed this program from a named semaphore to a regular file, so that the program would work with my system. Now I can add a SIGINT handler.
 
: I did read some ''sem_open()'' manual pages. I believed that a name of a named semaphore must start with "/"; but the program had "MyUniqueName", which starts not with "/". I also believed that ''sem_open()'' fails by returning SEM_FAILED; but the program checked NULL, not SEM_FAILED.
 
: I noticed that the program never used the semaphore as a semaphore. A program can do the same thing with shared memory (''shm_open()'' and ''shm_unlink()'') or with a regular file (''open()'' and ''unlink()''). So the solution with a regular file is as good as the solution with a semaphore. --[[User:Kernigh|Kernigh]] 02:43, 4 April 2011 (UTC)
 
== VB solution ==
Anonymous user