[autotest] Prevent signals from interrupting bgjob select polling.

We monitor the progress of a bg job by select polling. If the process
has a signal handler setup to ignore a signal like sigterm (which
upstart sends by default) and it's waiting on a background job, it
will still die because the select system call was interrupted thereby
raising an exception.

This cl enables processes that monitor bgjobs to decide if the
polling should continue through the signal handler.

TEST=Sent signals mid-poll and confirmed that polling continues.
     Added a unittest for the same.
BUG=chromium:403495

Change-Id: I26630b5cc3c980ffd2768b2c69c9eb6af44f0acf
Reviewed-on: https://chromium-review.googlesource.com/212376
Tested-by: Prashanth B <beeps@chromium.org>
Reviewed-by: Fang Deng <fdeng@chromium.org>
Commit-Queue: Prashanth B <beeps@chromium.org>
2 files changed