[gccsdk] UnixLib, Signals & Threading

Adam lists at snowstone.org.uk
Wed Jul 2 01:11:28 PDT 2008

In message <9b5e37b84f.Jo at hobbes.bass-software.com>, John Tytgat  wrote:

> In message <49d334b84f.admin at snowstone.org.uk>
>           Adam <lists at snowstone.org.uk> wrote:
> > In message <e2c419b54f.admin at snowstone.org.uk>, Adam  wrote:
> > > I'm trying to get my head around handling signals in a threaded app.
> > > However, I keep just getting a stack backtrace written to stderr. As
> > > far as I can tell my signal handler never gets a look in.
> > [big snip of example code]
> > 
> > Can anyone give me any pointers? Sorry if I've got it all wrong or am
> > asking a stupid question. Perhaps this is the wrong forum - can anyone
> > point me to a newsgroup or mailing list for discussing stuff like this
> > (e.g. non-ANSI C)?
> I can't immediately answer your questions as I think I don't see enough
> info to pinpoint what could be the cause.  I.e. what is the stacktrace
> you mentioned ?

It's just the backtrace you'd expect if there was no signal handler
active. I'm not sure if the contents of it are relevant as they relate
to the signal which caused the crash, rather than my non-functioning
signal handler, I think.

> You mentioned you "generate a synchronous signal".  How ?

Any number of ways! (I'm quite good at generating signals ;) For
instance, yesterday, by writing data over a pointer, rather than over
the region the pointer points to, or doing it deliberately with:
  int *ptr = (int*)0;
  *ptr = 1;

> An as simple as possible running example demonstrating your question could
> help us.

OK, I'll try and create a self-contained example, though the combination
of threads and signal handlers means it won't be that small :(

> BTW, a good start is probably "Advanced Programming in the UNIX®
> Environment " (ISBN 0201433079).

Great, thanks, I'll look that up.


Adam Richardson          Carpe Diem

More information about the gcc mailing list