libtextstyle: Implement reliable tty control.
* gnulib-local/lib/term-ostream.oo.c (DEBUG_SIGNALS): New macro.
Include <stdio.h>, <sys/stat.h>.
(NOFLSH): Define fallback value.
Include sig-handler.h, same-inode.h.
(ASYNC_SAFE): New macro.
(color_bgr): Mark as ASYNC_SAFE.
(nonintr_tcgetattr, nonintr_tcsetattr): New functions.
(log_message, sprintf_integer, simple_errno_string, simple_signal_string,
log_signal_handler_called): New functions.
(struct term_ostream): Add fields restore_colors, restore_weight,
restore_posture, restore_underline, tty_control, same_as_stderr.
(BLOCK_SIGNALS_DURING_NON_DEFAULT_STYLE_OUTPUT): New macro.
(term_fd): New variable.
(pgrp_status_t): New type.
(pgrp_status): New variable.
(update_pgrp_status): New function.
(out_stream): New variable.
(restore_colors, restore_weight, restore_posture, restore_underline): Remove
variables.
(out_color_change, out_bgcolor_change, out_weight_change, out_posture_change,
out_underline_change): New functions, extracted from out_attr_change.
(out_attr_change): Call these functions.
(restore): Use out_stream.
(tcsetattr_failed): New function.
(orig_lflag_set, orig_lflag): New variables.
(clobber_local_mode, restore_local_mode): New functions.
(job_control_signals): Renamed from stopping_signals. Add SIGCONT.
(num_job_control_signals): Renamed from num_stopping_signals.
(relevant_signal_set): Replaces stopping_signal_set.
(relevant_signal_set_initialized): New variable.
(init_relevant_signal_set): Replaces init_stopping_signal_set.
(block_relevant_signals): Replaces block_stopping_signals.
(unblock_relevant_signals): Replaces unblock_stopping_signals.
(is_ignored): New function.
(show_signal_marker): New function.
(fatal_or_stopping_signal_handler, fatal_signal_handler,
stopping_signal_handler, continuing_signal_handler,
ensure_continuing_signal_handler, ensure_other_signal_handlers): New functions.
(activate_non_default_attr, deactivate_non_default_attr): Rewritten.
(term_ostream::free): Unset term_fd and call update_pgrp_status.
(term_ostream_create): Initialize the fields restore_colors, restore_weight,
restore_posture, restore_underline, tty_control, same_as_stderr. Call
init_relevant_signal_set. Set term_fd and call ensure_continuing_signal_handler
and update_pgrp_status.
* gnulib-local/m4/term-ostream.m4 (gl_TERM_OSTREAM): Check for tcgetattr.
* gnulib-local/modules/term-ostream (Depends-on): Add sigaction, same-inode.
* libtextstyle/NEWS: Mention the change.