+# Try to check existing Kerberos credentials.
+sub check_credentials {
+ system "klist", "-s";
+ return 1 if $? < 0;
+ return 0 unless $?;
+ kill USR1, $tmux_helper;
+ return 111;
+}
+
+# We were signalled by our child which noticed that our credentials expired.
+sub want_credentials {
+ # Do we already know?
+ return if defined $have_valid_credentials && $have_valid_credentials == 0;
+ $SIG{USR1} = IGNORE;
+ $have_valid_credentials = 0;
+ system "tmux", "new-window", "exec kinit";
+}
+
+# We were signalled by our child which noticed that our credentials are valid.
+sub got_credentials {
+ $have_valid_credentials = 1;
+ $SIG{USR1} = \&want_credentials;
+}
+