Group: comp.lang.c++
From: Ian Collins
Date: Friday, April 11, 2008 6:41 PM
Subject: Re: When an application crashes...

Alexander Dong Back Kim wrote:
>
> The problem of semaphore is, although they works beautifully, if a
> process lock the semaphore and crashes immediately after the lock,
> then the lock won't be unlocked. Therefore, there is no way other
> applications can access the locked resource. Because of this reason, I
> think I have to somehow protect unexpected terminations. In other
> words, in order to unlock the resource before the process dies, I
> think I have to catch some system message or destructor of the class.
> I tried destructor way but it didn't call the destructor when the
> application is unexpectedly killed.
>
> Any suggestion for solving this problem?
>
Yes, ask the experts on either a linux group or comp.unix.programmer.
There are a number of issues tied up on your question, some are system
specific (Sys V IPC) other more generic programming (how do you manage
possibly corrupt shared data if process crashes with a lock held).

Have fun.

--
Ian Collins.

Safety Articles | Usenet Groups | Usenet News | Bluegrass