This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: determine whether code is running in a signal handler context


It was thus said that the Great Yubin Ruan once stated:
> Hi,
> 
> I am writing to see if this is any util functions in libc that can
> help to determine it is currently running in a signal.
> 
> I wrote some library and provide a function which will be used in many
> client code. However this function is not async-signal safe (it calls
> malloc(3)) so when it is called, I want to detect whether it is
> currently running in a signal handler. If it is, I can avoid calling
> those not-async-signal-safe functions which might cause deadlock.

  Wouldn't it be easier to just document (in as large a font as you care to)
that none of the functions in your library can be used in a signal handler,
and if they are, it's "undefined behavior"?

  -spc


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]