Sentinel support

Was #452.
`pids` is unknown here. Make it a global variable.