@@ -165,7 +165,7 @@ cleanup_signal(int sig)
165165 else {
166166 // This shouldn't happen. Exit in case subcommand tracking failed (this
167167 // is what we silently did before).
168- debug_print ( "received SIGCHLD for unknown child (subcommand_pid=%d win32_pid=%d)" , subcommand_pid , win32_pid );
168+ fprintf ( stderr , "received SIGCHLD for unknown child (subcommand_pid=%d win32_pid=%d)" , subcommand_pid , win32_pid );
169169 status = 55 ;
170170 }
171171 }
@@ -526,7 +526,7 @@ check_tty_gone()
526526 // Controlling terminal is gone
527527 cleanup_exit (0 );
528528 else
529- warnx ("checking controlling terminal failed" );
529+ warn ("checking controlling terminal failed" );
530530 }
531531 else
532532 // We are still attached to a terminal
@@ -783,7 +783,7 @@ main(int argc, char *argv[])
783783 return 0 ;
784784
785785 case 'v' :
786- printf ("ssh-agent-wsl 2.1 \n" );
786+ printf ("ssh-agent-wsl 2.2 \n" );
787787 printf ("Based on weasel-pageant, copyright 2017, 2018 Valtteri Vuorikoski\n" );
788788 printf ("Based on ssh-pageant, copyright 2009-2014 Josh Stone\n" );
789789 printf ("License GPLv3+: GNU GPL version 3 or later"
@@ -967,6 +967,11 @@ main(int argc, char *argv[])
967967 signal (SIGCHLD , cleanup_signal );
968968 }
969969#else
970+ // Detach from process group but not the session to keep the controlling
971+ // tty but avoid receiving the foreground process group's signals. See
972+ // comments for check_tty_gone on why these tricks are needed.
973+ else if (setpgid (0 , 0 ) < 0 )
974+ cleanup_warn ("setpgid" );
970975 else
971976 // Set up SIGCHLD handler to catch the helper process exiting
972977 signal (SIGCHLD , cleanup_signal );
0 commit comments