Skip to content

Commit

Permalink
src/vipw.c: Restore the original terminal pgrp after editing
Browse files Browse the repository at this point in the history
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: 7eca111 (2019-11-11; "Fix vipw not resuming correctly when suspended")
Closes: <#1194>
Reported-by: <https://github.com/yonecle>
Tested-by: Alejandro Colomar <[email protected]>
Reviewed-by: Alejandro Colomar <[email protected]>
  • Loading branch information
millert authored and alejandro-colomar committed Jan 24, 2025
1 parent 76727c3 commit 7dcb9a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/vipw.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,14 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
}
}

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);
Expand Down

0 comments on commit 7dcb9a0

Please sign in to comment.