Safe way of writing data to file in signal handler ?

Is there a preferred method of writing data to a file while in a signal
handler (QNX 4.25) ? I notice that fprintf is not a “signal safe function”.

I am curious to find out how others handled the problem where processes
which need to be shutdown immediatley (ie. via signals in our case) also
need to write some data to a file to retain some critical info ?

We have “illegaly” used fprintf in signal handlers with mixed results -most
times the data gets written and sometimes it is not.

Rich

Richard Tyc <richt@sbrc.ca> wrote:

Is there a preferred method of writing data to a file while in a signal
handler (QNX 4.25) ? I notice that fprintf is not a “signal safe function”.

Use the Posix file functions, in particular write().

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.