[misc] Utility to wrap the code that needs to trap exits.
[misc] Utility to wrap the code that needs to trap exits.

But only temporarily. The wrapped code is free to deal with the EXIT
messages in any suitable way. But if the exit messages are left in the
mailbox, they are handled as if trap_exit was false. That is, if
something exits with reason 'normal', we ignore that. Everything else
results in immediate termination.

So the simplest use case is something like this:

misc:with_trap_exit(fun () -> dont_interrupt_me() end).

So the dont_interrupt_me/0 is indeed not interrupted (modulo the
exit(_, kill) obviously). But once it's done the delayed exits are
processed.

Change-Id: I1b1100cb65b863b76cc2c5d88b2026dd53251828
Reviewed-on: http://review.couchbase.org/88206
Tested-by: Aliaksey Artamonau <ce14b1c16e0fd654f926118eb8addbec5aff4ffa@couchbase.com>
Well-Formed: Build Bot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Artem Stemkovski <15a0730a27c69f62ab86f2b6c639fca202166c02@couchbase.com>

membase/ns_server,membase/ns_server,membase/ns_server,membase/ns_server,membase/ns_server,membase/ns_server