ioslave terminating mechanism
Malte Starostik
malte at kde.org
Thu Apr 18 10:47:04 BST 2002
Am Thursday 18 April 2002 01:52 schrieb Waldo Bastian:
> On Wednesday 17 April 2002 04:53 pm, aleXXX wrote:
> > On Thursday 18 April 2002 01:08, Waldo Bastian wrote:
> > > That's nice and all but it fails to take into account that signal
> > > delivery is asynchronous and the current code can deadlock when the
> > > siganl happens to arrive at an inconvenient time. E.g. within a malloc
> > > or free call. When you then call the destructor your process will
> > > deadlock.
> > >
> > > You simply can't call arbitrary code (the destructor of a slave) at any
> > > arbitrary moment (when the signal arrives) and expect it to work.
> >
> > Ok, so how about setting a flag in the signal handler which is checked in
> > dispatchLoop() and if it is set call the dtor from there ?
>
> That sounds like a much better approach, although you will have to think of
> ways to make a slave exit which happens to be stuck on a DNS lookup or
> something.
So maybe the handler sets a flag and calls alarm(5), so the flag is checked
right after the select() in the main loop, and on SIGALRM the slave
terminates so it had 5 seconds to shutdown cleanly?
--
Malte Starostik
PGP: 1024D/D2F3C787 [C138 2121 FAF3 410A 1C2A 27CD 5431 7745 D2F3 C787]
More information about the kde-core-devel
mailing list