X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=opt%2Fbin%2Fktmux_helper;h=e2b58a50cb4ffe9ef7741a49aac9e0afb4153eb4;hp=fe942d4869d5c2537f9a9f1b7a08a42f3f4549d6;hb=0d1d3e8398fd0d7844edf1e2ad13d1adc245de17;hpb=5238da68cdb1f51a416564a0faeb909f25d9b168 diff --git a/opt/bin/ktmux_helper b/opt/bin/ktmux_helper index fe942d4..e2b58a5 100755 --- a/opt/bin/ktmux_helper +++ b/opt/bin/ktmux_helper @@ -5,6 +5,7 @@ # Options: -I Specify path to kinit. # -L Specify path to klist. # -R Specify path to krenew. +# -T Specify path to tmux. # Notes: Doesn't handle multiple sessions properly. # @@ -27,11 +28,14 @@ exit 0 if $tmux_helper; $tmux_helper = $$; my %opts; -getopts('I:L:R:', \%opts); +getopts('I:L:R:T:', \%opts); my $kinit = $opts{'I'} || "kinit"; my $klist = $opts{'L'} || "klist"; my $krenew = $opts{'R'} || "krenew"; +my $tmux = $opts{'T'} || "tmux"; + +my $avoid_race = 0; my $exitasap = 0; my $pid = 0; @@ -109,9 +113,12 @@ sub check_credentials { # We were signalled by our child which noticed that our credentials expired. sub want_credentials { + return sleep 1 if $avoid_race; + $avoid_race = 1; # Do we already know? - return sleep 1 if &check_kinit_child; - system "tmux", "new-window", "-n", "Renew Kerberos credentials", "exec $kinit"; + system $tmux, "new-window", "-n", "Renew Kerberos credentials", "exec $kinit" unless &check_kinit_child; + sleep 1; + $avoid_race = 0; } sub cleanup {