I recently had some difficulties when trying to use tcsetpgrp(3) from a process trying to bring itself as the foreground process group leader of its controlling terminal. The process got a SIGTTOU sent, that was unexpected as this signal is not mentioned at all in the tcsetpgrp(3) manpage. I eventually found an enlightening mention of this signal and how to handle it in an unanticipated location, the manual of an old release of the SAS/C compiler. "If tcsetpgrp is called from a background process, the signal SIGTTOU is generated, unless the signal is ignored or blocked. If the signal is defaulted, this will cause the calling process to stop. If the signal is handled, tcsetpgrp will set errno to EINTR and fail. For this reason, you should ignore or block SIGTTOU if you call tcsetpgrp from a background process." See https://support.sas.com/documentation/onlinedoc/ccompiler/doc750/html/lr2/zid-9675.htm I think an explanation of the role of SIGTTOU and its usage relative to tcsetpgrp(3) should be added to the manual page as it plays an important role in the correct application of this library function.
Created attachment 235014 [details] tcsetpgrp(3) test program A test program that may help explore the behavior of tcsetpgrp(3).