Add a signal handler to pause.

It returns 0 when a signal is received.

Fixes #1496