1*19261079SEd Maste# $OpenBSD: agent-subprocess.sh,v 1.1 2020/06/19 05:07:09 dtucker Exp $ 2*19261079SEd Maste# Placed in the Public Domain. 3*19261079SEd Maste 4*19261079SEd Mastetid="agent subprocess" 5*19261079SEd Maste 6*19261079SEd Mastetrace "ensure agent exits when run as subprocess" 7*19261079SEd Maste${SSHAGENT} sh -c "echo \$SSH_AGENT_PID >$OBJ/pidfile; sleep 1" 8*19261079SEd Maste 9*19261079SEd Mastepid=`cat $OBJ/pidfile` 10*19261079SEd Maste 11*19261079SEd Maste# Currently ssh-agent polls every 10s so we need to wait at least that long. 12*19261079SEd Masten=12 13*19261079SEd Mastewhile kill -0 $pid >/dev/null 2>&1 && test "$n" -gt "0"; do 14*19261079SEd Maste n=$(($n - 1)) 15*19261079SEd Maste sleep 1 16*19261079SEd Mastedone 17*19261079SEd Maste 18*19261079SEd Masteif test "$n" -eq "0"; then 19*19261079SEd Maste fail "agent still running" 20*19261079SEd Mastefi 21*19261079SEd Maste 22*19261079SEd Masterm -f $OBJ/pidfile 23