188 |
if (on == jobctl || rootshell == 0) |
if (on == jobctl || rootshell == 0) |
189 |
return; |
return; |
190 |
if (on) { |
if (on) { |
191 |
int ofd; |
fd = open(_PATH_TTY, O_RDWR); |
|
ofd = fd = open(_PATH_TTY, O_RDWR); |
|
192 |
if (fd < 0) { |
if (fd < 0) { |
193 |
fd += 3; |
fd += 3; |
194 |
while (!isatty(fd) && --fd >= 0) |
while (!isatty(fd)) |
195 |
; |
if (--fd < 0) |
196 |
|
goto out; |
197 |
} |
} |
198 |
fd = fcntl(fd, F_DUPFD, 10); |
fd = savefd(fd); |
|
close(ofd); |
|
|
if (fd < 0) |
|
|
goto out; |
|
|
fcntl(fd, F_SETFD, FD_CLOEXEC); |
|
199 |
do { /* while we are in the background */ |
do { /* while we are in the background */ |
200 |
if ((pgrp = tcgetpgrp(fd)) < 0) { |
if ((pgrp = tcgetpgrp(fd)) < 0) { |
201 |
out: |
out: |