[Bug 3181] ssh-agent doesn't exit automatically after child program exits

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Fri Jun 19 13:47:17 AEST 2020


https://bugzilla.mindrot.org/show_bug.cgi?id=3181

Darren Tucker <dtucker at dtucker.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vinschen at redhat.com

--- Comment #4 from Darren Tucker <dtucker at dtucker.net> ---
(In reply to Serge B from comment #2)
> 1. OpenCYGWIN_NT-10.0 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64
> CygwinSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
> 
> Cygwin version remains live forever.

OK, the reason for that is in check_parent_exists():
{
        /*
         * If our parent has exited then getppid() will return
(pid_t)1,
         * so testing for that should be safe.
         */
        if (parent_pid != -1 && getppid() != parent_pid) {
                /* printf("Parent has died - Authentication agent
exiting.\n"); */
                cleanup_socket();
                _exit(2);
        }

In this mode, when the ssh-agent forks the agent itself continues as
the child while the parent execs the requested command which is
unusual.  I'm not entirely sure why this is, but I suspect it's so job
control works as expected on the executed command.

Based on local testing, on Cygwin getppid() continues to return the
original process id even if that process has exited, instead of being
"reparented" to init as it would be on a Unixlike system.  The best
solution we could come up with was to fall back to "kill(getppid(), 0)"
on Cygwin to test for parent process existence, however that'll be
wrong in the case of pid reuse.  Corinna, do you have any better ideas?

-- 
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list