From: Todd C. Miller Date: Fri, 24 Jan 2025 02:11:09 +0000 (-0700) Subject: src/vipw.c: Restore the original terminal pgrp after editing X-Git-Tag: 4.17.3~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3b12ab7e29b0f3c766b39269da76a5ef3a753b22;p=thirdparty%2Fshadow.git src/vipw.c: Restore the original terminal pgrp after editing 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: Reported-by: Tested-by: Alejandro Colomar Reviewed-by: Alejandro Colomar --- diff --git a/src/vipw.c b/src/vipw.c index a855e0d7f..dbc87db9a 100644 --- a/src/vipw.c +++ b/src/vipw.c @@ -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);