returning -1. Also change checks from "saved_pgrp != -1" to
"fd != -1". Coverity CID 104098.
int fd = open(_PATH_TTY, O_RDWR|O_NOCTTY, 0);
if (fd != -1) {
saved_pgrp = tcgetpgrp(fd);
+ if (saved_pgrp == -1) {
+ close(fd);
+ fd = -1;
+ }
+ }
+ if (saved_pgrp != -1) {
/*
* Child was stopped trying to access controlling
* terminal. If the child has a different pgrp
SIGTSTP);
}
}
- if (fd != -1) {
+ if (saved_pgrp != -1) {
/*
* Restore command's process group if different.
* Otherwise, we cannot resume some shells.