[GDBserver] Block and unblock SIGIO
Nowadays, GDBserver disables async io (by ignoring SIGIO) when process
a serial event, and enables async io (by installing signal handler) when
resume the inferior and wait. GDBserver may miss SIGIO (by interrupt)
and doesn't process SIGIO in time, which is shown by
gdb.base/interrupt-noterm.exp. In the test, GDB sends "continue &" and
then "interrupt". if '\003' arrives at a period between GDBserver
receives vCont;c and enables async io, SIGIO is ignored because signal
handler isn't installed. GDBserver waits for the inferior and can not
notice '\003' until it returns from wait.
This patch changes the code to install SIGIO handler early, but block
and unblock SIGIO as needed. In this way, we don't remove SIGIO
handler, so SIGIO can't be ignored. However, GDBserver needs to
remove the signal handler when connection is closed.
gdb/gdbserver:
2016-01-26 Yao Qi <yao.qi@linaro.org>
* remote-utils.c (remote_close) [!USE_WIN32API]: Ignore SIGIO.
(unblock_async_io): Rename to ...
(block_unblock_async_io): ... it. New function.
(enable_async_io): Don't install SIGIO handler. Unblock it
instead.
(disable_async_io): Don't ignore SIGIO. Block it instead.
(initialize_async_io): Install SIGIO handler. Don't call
unblock_async_io.