Return -1 with EINVAL if pgid < 0. Previously tcsetpgrp() would blindly go ahead and set the pgid of the controlling terminal to a negative value, causing later calls to various functions to fail. For example, gdb has code like the following: tcsetpgrp (0, getpgid (inf->pid)); If getpgid (inf->pid) fails (returns -1), then this code would set the pgid of fd 0 to -1, so that some later calls to getpgid() would also return -1. This caused the problem reported here: https://cygwin.com/ml/cygwin/2019-07/msg00166.html.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cygwin documentation is available on the net at https://cygwin.com You might especially be interested in https://cygwin.com/faq/faq.html#faq.programming.building-cygwin