On 04 Jan 2012, at 14:14, ik wrote:

As I understand (I hope I'm wrong), memory allocations inside a signal
handler is unsafe. Is that true ?

Yes. The reason is that signals could be raised at any point during the execution, including e.g. while a heap manager routine was already being executed.

Further-more, I wish to reload configuration under SIGHUP (it's a daemon
application). What is the safest way in your opinion to do so ?

The only safe way to do almost anything using a signal handler is to set a global variable in the handler and return, and in your program regularly check this global variable to see whether you have to do anything.

For example let's say we have a configuration files regarding database
access.
How safe will it be to re-read the settings and close and reopen the
connection on SIGHUP ?

About as unsafe as you can get.

Another question, is it possible to use exitproc if SIGKILL is sent, or
there is nothing I can do at all ?

SIGKILL and SIGSTOP cannot be caught in any way.

And last question for now, is there a more FPC way to handle such issues ?

Unix signals are unix signals. There is no FPC wrapper over them. Adding one wouldn't help much, since as mentioned above you can do almost nothing from a signal handler.


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to