Re: translating "create Semaphore" to Linux



GHUM wrote:
hSem = win32event.CreateSemaphore (None, 1,
1,"stringincludinginterfaceandport")
rt=win32event.WaitForSingleObject (hSem, 0)
if rt != win32event.WAIT_TIMEOUT:
really_do_start_my_app()
else:
print "application allready running"

to make sure that only ONE instance of the application is running at a
time.


Running a serious risk of teaching my grandmother, but...

.... why use a Semaphore rather than a Mutex? Or why not
simply use the bound socket as its own mutex? I know
Windows won't allow you to rebind the same socket to the
same addr/port in two different processes (unless perhaps
you play some trickery with the socket options).

TJG
.



Relevant Pages

  • Re: How to cancel select() call ?
    ... I have to release any mutex before I enter selectand during that time, ... socket, with the same descriptor, can be created by other thread / there are ... there is a time when socket descriptor will be invalid." ... But after selectexits and before I create disposable socket again ...
    (microsoft.public.win32.programmer.networks)
  • Re: How to cancel select() call ?
    ... after releasing mutex and before entering select, socket can be closed by ... Your socket descriptor is never released, ...
    (microsoft.public.win32.programmer.networks)
  • Re: How to cancel select() call ?
    ... after releasing mutex and before entering select, socket can be closed by ... there is a time when socket descriptor will be invalid." ... But after selectexits and before I create disposable socket again ...
    (microsoft.public.win32.programmer.networks)
  • Re: reuse of socket handles
    ... all other users of pContext will get a NULL socket. ... One is performing blocking recvfrom() calls on ... >> first thread calls recvfromit will be operating on the new socket ... >> Say you try to protect the socket with a mutex and all threads ...
    (microsoft.public.win32.programmer.kernel)
  • Re: reuse of socket handles
    ... One is performing blocking recvfrom() calls on the ... socket and the second one closes the socket. ... Say you try to protect the socket with a mutex and all threads ...
    (microsoft.public.win32.programmer.kernel)