Unix Programming - catch a signal with non atomic method inside?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2005 > catch a signal with non atomic method inside?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author catch a signal with non atomic method inside?
ul

2005-11-23, 5:54 pm

Hello everybody,

Sorry, for maybe simple question. But it is important for my
understanding.
So, suppose we have a function that is registered as a
signal(SIGCHLD,foo);

foo loks like
void foo (int)
{
// some nonatomic
LOG << bla << bla << bla << end;
}

of course, there is somewhere in the application a lot of LOG methods
called
Now the question, is this code safe?
Could it be that my log file will be messed?

Thanks

David Schwartz

2005-11-23, 5:54 pm


"ul" <yuliy@gmx.de> wrote in message
news:1132761926.469261.111750@g43g2000cwa.googlegroups.com...

> Hello everybody,
>
> Sorry, for maybe simple question. But it is important for my
> understanding.
> So, suppose we have a function that is registered as a
> signal(SIGCHLD,foo);
>
> foo loks like
> void foo (int)
> {
> // some nonatomic
> LOG << bla << bla << bla << end;
> }
>
> of course, there is somewhere in the application a lot of LOG methods
> called
> Now the question, is this code safe?


Nope. What if some other LOG method is in progress at the time the
signal is received?!

> Could it be that my log file will be messed?


Definitely.

DS


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com