This fixes a problem when the shell is not in monitor mode (job control
enabled) which resulted in the terminal pgrp being set to an invalid
value once vipw exited.
Fixes: 7eca1112fbd7 (2019-11-11; "Fix vipw not resuming correctly when suspended")
Closes: <https://github.com/shadow-maint/shadow/issues/1194>
Reported-by: <https://github.com/yonecle>
Tested-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
}
}
- if (orig_pgrp != -1)
+ if (orig_pgrp != -1) {
+ /* Restore terminal pgrp after editing. */
+ if (tcsetpgrp(STDIN_FILENO, orig_pgrp) == -1) {
+ fprintf(stderr, "%s: %s: %s", Prog,
+ "tcsetpgrp", strerror(errno));
+ }
sigprocmask(SIG_SETMASK, &omask, NULL);
+ }
if (-1 == pid) {
vipwexit (editor, 1, 1);