It makes sense that it was designed for handling repeated calls and I can't find any other code that does this extra check so it is indeed redundant.
> Why prevent registering callbacks for signals where the old action is SIG_IGN?
>
> I guessing this is not necessary.
I based this off nsProfileLock's CATCH_SIGNAL() which does not register for signal handlers that have already been set to SIG_IGN. I guess the logic is that if some other component has already chosen to ignore the signal then there is probably a good reason for that and we shouldn't interfere. It would also be inconsistent if we treated it like normal, started shutdown and then restored SIG_IGN which would not follow through with killing the process for subsequent termination attempts. It is always possible to change the signal handler to something else before calling RegisterCallback() to get around this if need be.
> SIG_DFL is typically 0.
>
> I assume this is intended to detect when oldAction has not been set, but mSignalInfo elements are added only when the old action is successfully retrieved.
>
> Can this check just be dropped?
Yeah this evolved into something bad, check is redundant and SIG_DFL needs to be restorable (oops!).
Comment on attachment 8959924 SIGINT/ SIGHUP and quit application gracefully.
Bug 336193 - P1: Use SignalPipeWatcher to detect signals SIGTERM/
https:/ /reviewboard. mozilla. org/r/228682/ #review235302
> Is the |dispatchQuit| single quit logic necessary? :mShuttingDown already ensures that multiple Quit() calls will be harmless. /searchfox. org/mozilla- central/ rev/b29daa46443 b30612415c35be0 a3c9c13b9dc5f6/ toolkit/ components/ startup/ nsAppStartup. cpp#393
> It looks like nsAppStartup:
>
> https:/
It makes sense that it was designed for handling repeated calls and I can't find any other code that does this extra check so it is indeed redundant.
> Why prevent registering callbacks for signals where the old action is SIG_IGN?
>
> I guessing this is not necessary.
I based this off nsProfileLock's CATCH_SIGNAL() which does not register for signal handlers that have already been set to SIG_IGN. I guess the logic is that if some other component has already chosen to ignore the signal then there is probably a good reason for that and we shouldn't interfere. It would also be inconsistent if we treated it like normal, started shutdown and then restored SIG_IGN which would not follow through with killing the process for subsequent termination attempts. It is always possible to change the signal handler to something else before calling RegisterCallback() to get around this if need be.
> SIG_DFL is typically 0.
>
> I assume this is intended to detect when oldAction has not been set, but mSignalInfo elements are added only when the old action is successfully retrieved.
>
> Can this check just be dropped?
Yeah this evolved into something bad, check is redundant and SIG_DFL needs to be restorable (oops!).