### along with this program; if not, write to the Free Software Foundation,
### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-## things to do
-##
-## pidfiles
-
my $VERSION = "0.1.0~unfinished";
use strict;
return $l->l_type != F_UNLCK;
}
+sub write_to_file ($$) {
+ my ($file, $contents) = @_;
+ my $new = "$file.new";
+ open my $fh, ">", $new or sysfail "couldn't open `$new' for writing: $!";
+ print $fh $contents;
+ $fh->flush && !$fh->error && close $fh
+ or sysfail "failed to write to `$new': $!";
+ rename $new, $file or sysfail "failed to rename `$new' to `$file': $!";
+}
+
my $INKIDP = 0;
sub myfork () {
my $kid = fork;
$s->{"_ssh_stdin"} = $win;
$s->{"_ssh_stdout"} = $rout;
$KIDMAP{$kid} = [$s, "SSH tunnel"];
+ write_to_file "$SESSDIR/ssh-$server.pid", "$kid\n";
}
}
exec @args or sysfail "failed to exec `$prog': $!";
}
$CLIENTKID = $kid;
+ write_to_file "$SESSDIR/client.pid", "$kid\n";
}
sub accept_loop () {