Here's an example I'm rather proud of. It involves setting getpid(2) as a signal handler(2) via JNA.
https://github.com/facebook/buck/commit/48f1e201a966b9e2adab...
https://github.com/facebook/buck/commit/48f1e201a966b9e2adab...
The result is the same though; I forgot that signal mask is not reset on exec. Damn POSIX signals!