Skip to content

Commit

Permalink
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 #1194.
  • Loading branch information
millert committed Jan 24, 2025
1 parent 76727c3 commit d61b626
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 d61b626

Please sign in to comment.