Hi Daniel,

thanks for your reply.

The current version of the Program only supports windows. I'd hoped that there would be an improvement
to the mutex-handling in the apr in future releases.

I've got about 4 months. Until then, linux support for this particular part is needed. If there is no improvement until then, i'll have to write a similar plattform-dependent part into that part of
the software.

Hans-Peter

Daniel May schrieb:
Peter,
        We ended creating a C++ class the manages Linux and Windows
shared memory and mutexes.  The Windows version always tries to open an
existing shared mem first, if to fails we then decide if we want to
create it.  Under Linux, we store the PID in the shared memory, so we
can then query if the process who created it is still alive.
There is no generic way to determine if a process is running under both
Windows and Linux, you have to #ifdef

Daniel

-----Original Message-----
From: Hans-Peter Weidinger [mailto:[EMAIL PROTECTED] Sent: Monday, May 15, 2006 8:22 AM
To: Daniel May; [email protected]
Subject: Re: apr_proc_trylock for linux

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:[EMAIL PROTECTED]
Sent: Monday, May 15, 2006 7:57 AM
To: [email protected]
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




--

Weidinger Hans-Peter
------------------------------------------------------------------------
Weidinger Hans-Peter Softwaredienstleistungen und Beratung
Sebekstrasse 21
4400 Steyr

Tel.: +43 676 9134882
Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Weidinger Hans-Peter
------------------------------------------------------------------------

Reply via email to