kernel: Save and restore thread signal information

Save and restore each thread signal mask and signal stack. A new function
set_signalstack() is introduced which performs sanity check on a given
signal stack configuration and then sets it together with some required
additional LWP flags.