Anthony Liguori wrote:
> Thread and signal safety are slightly different.

They are very different:

Virtually all libc calls are thread safe, unless they use unsafe
static data APIs.

On the other hand, the number of libc calls that are signal safe is
very limited.

For example, calling printf() is not signal-safe; neither is malloc().

pthread functions are not safe in signal handlers either:
pthread_self, pthread_getspecific, pthread_mutex_lock and
pthread_cond_broadcast, not of them are signal-safe.

In a nutshell, it's dubious to do much inside a signal handler.

Pure system calls tend to be ok, though.

> Scheduling an idle 
> callback from a signal handler is a pretty reasonable thing to do.

Scheduling, yes, by telling the main event loop that it's time.

Running it inside the signal handler... Then you're depending on
non-portabilities among hosts.

-- Jamie


Reply via email to