apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans-Peter Weidinger <hans-pe...@hp-weidinger.at>
Subject Re: apr_proc_trylock for linux
Date Mon, 15 May 2006 13:21:38 GMT
Hi Daniel,

thanks for the answer.

Unfortunately shared memory has a similar problem. My first try to 
create a shared mem segment.
Windows destroys this segment, if the last handle to the segement is 
closed and the creating process dies.

Unix keeps the memory segment alive. Thats why i cannot determine, if 
the process, that created the
SHM-Segment is still alive.

My first try was to use named pipes to do IPC. This is not implemented 
for Windows. Until now i did not find
any mechanism that allows my to see if a process is already running in a 
plattform independent matter.
(i want to get around those #ifdef WIN32 as far as possible)

Intention: If a second instance of the process is started, the command 
line parameter should be given to the first
instance and then terminate immediately.

@anyone on the list:
Does anyone know, if apr_proc_trylock a subject to be added for linux (i 
could live with that) or is this permanent?

Thanks

Hans-Peter

> I ran into this same problem.  I used the apr_proc_mutex_trylock under
> windows to check if a process is already running.  This does not work
> under other OS's.  My solution was to create a shared memory segment to
> store sharable pthread mutex information.  Not very portable, but solved
> my problem.
>
> The apr proc mutex's seem to favor being inherited rather than working
> between two unrelated processes.
>
> /Daniel May
>
>
> -----Original Message-----
> From: Hans-Peter Weidinger [mailto:hans-peter@hp-weidinger.at] 
> Sent: Monday, May 15, 2006 7:57 AM
> To: dev@apr.apache.org
> Subject: apr_proc_trylock for linux
>
> I've written an application that should recognize, if another instance
> of the process is already running.
> The app should run under linux and windows.
>
> Unfortunately i've developed it under Windows, and used a process mutex
> to find out, if another instance is running.
>
> I've used the "apr_proc_mutex_trylock" to check for other processes.
>
> unfortunately when moving to linux i found out, that this is a
> "windows-only"-feature.
>
> Is there any way (or version) to activate the trylock mechanism for
> unix?
>
> Any hint appreciated.
>
> Hans-Peter
>
>   


Mime
View raw message