react on process death immediately
react on process death immediately

There was a race that if we get SIGCHLD before we go to sleep(), we
would have to wait whole grace period. This patch uses alarm() to
break out of waitpid() which allows to use waitpid() in blocking mode.

Another race was if child dies before we establish signal handler for
SIGCHLD. In this case we would wait till stdin is closed. We address
that by setting signal actions before forking. This should not affect
child as exec() resets signal actions to default in this case.

Another race was if we get signal before doing fgets(). We address that
by closing stdin from signal handler.

Change-Id: Ifd6cd1846c97d2fb96cdfb95831919e4bc962a38
Reviewed-on: http://review.northscale.com/1171
Reviewed-by: Sean Lynch <9c3328a4a1f4f8f5c18b2d5b9057163c49b93ff3@literati.org>
Tested-by: Sean Lynch <9c3328a4a1f4f8f5c18b2d5b9057163c49b93ff3@literati.org>

membase/vbucketmigrator,membase/vbucketmigrator,zbase/vbucketmigrator,membase/vbucketmigrator,membase/vbucketmigrator,zbase/vbucketmigrator,zbase/vbucketmigrator,zbase/vbucketmigrator