trap: Implement POSIX.1-2008 trap reset behaviour