0

I realize this is kind of a silly question that I'm pretty sure I will be able to. But, if I were to install a signal handler in a function other than main, is it safe to assume the signal handler will remain after returning from the method?

TemporaryFix
  • 2,008
  • 3
  • 30
  • 54

1 Answers1

1

Yes, you can do it in a separate function, signal() does not have to be done in the main() function, it can be done anywhere in the call stack.

The call to signal() associates a signal number to an action, and the action may be a function address. There is no transient information (like stack variables or dynamic memory) that needs to be kept around after the association.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953