Fix signal handler attach

The signal handler routine should be attached outside of the definition, I saw that it was correctly done in the original patch but somehow got mangled