[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Half-ugly fullscreen applications, how to recover when things go bump



Hi,

On Friday 31 July 2009, Peter Persson wrote:
> Ok, there's no turning back now, I finally have to learn about
> signals. Thanks!

Some comments on signals from Linux, I guess they're valid on MiNT too:
1) because signal context is asynchronous to other program state,
    don't call within the signal handler anything that may (even indirectly)
    modify global program state which could be modified also elsewhere at
    the same time.  Such unsafe function are e.g. allocations and printf
   (which can do allocs).
   - signals interrupt system calls like select().  If program goes through
     one regulargly, just set a global variable in signal handler and check
     that each time select() returns.  (more complicated method would be to
     write a byte to pipe in the signal handler and adding the other end of
     the pipe to the select)
2) use sigaction() as signal() has different kinds of issue
    (non-portable etc)
3) do not mix threading and signals (depending on which threading library
    is used, signal may be delivered to a "random" thread etc)


	- Eero