Skip to content

Commit

Permalink
sh: Explain duplicate tcsetpgrp() calls
Browse files Browse the repository at this point in the history
This is a comment change only.
  • Loading branch information
jillest committed Dec 26, 2020
1 parent b63eeef commit ab41d7f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/sh/jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,12 @@ forkshell(struct job *jp, union node *n, int mode)
pgrp = jp->ps[0].pid;
if (setpgid(0, pgrp) == 0 && mode == FORK_FG &&
ttyfd >= 0) {
/*** this causes superfluous TIOCSPGRPS ***/
/*
* Each process in a pipeline must have the tty
* pgrp set before running its code.
* Only for pipelines of three or more processes
* could this be reduced to two calls.
*/
if (tcsetpgrp(ttyfd, pgrp) < 0)
error("tcsetpgrp failed, errno=%d", errno);
}
Expand Down

0 comments on commit ab41d7f

Please sign in to comment.