~mdw
/
with-authinfo-kludge
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b17683b
)
with-authinfo-kludge: Actually write pidfiles like the manual says.
author
Mark Wooding
<mdw@distorted.org.uk>
Sun, 24 Apr 2016 22:30:30 +0000
(23:30 +0100)
committer
Mark Wooding
<mdw@distorted.org.uk>
Tue, 26 Apr 2016 19:32:26 +0000
(20:32 +0100)
with-authinfo-kludge
patch
|
blob
|
blame
|
history
diff --git
a/with-authinfo-kludge
b/with-authinfo-kludge
index
112668e
..
47660a4
100755
(executable)
--- a/
with-authinfo-kludge
+++ b/
with-authinfo-kludge
@@
-21,10
+21,6
@@
### along with this program; if not, write to the Free Software Foundation,
### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
### 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;
my $VERSION = "0.1.0~unfinished";
use strict;
@@
-167,6
+163,16
@@
sub lockedp ($) {
return $l->l_type != F_UNLCK;
}
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;
my $INKIDP = 0;
sub myfork () {
my $kid = fork;
@@
-693,6
+699,7
@@
EOF
$s->{"_ssh_stdin"} = $win;
$s->{"_ssh_stdout"} = $rout;
$KIDMAP{$kid} = [$s, "SSH tunnel"];
$s->{"_ssh_stdin"} = $win;
$s->{"_ssh_stdout"} = $rout;
$KIDMAP{$kid} = [$s, "SSH tunnel"];
+ write_to_file "$SESSDIR/ssh-$server.pid", "$kid\n";
}
}
}
}
@@
-782,6
+789,7
@@
sub run_client (@) {
exec @args or sysfail "failed to exec `$prog': $!";
}
$CLIENTKID = $kid;
exec @args or sysfail "failed to exec `$prog': $!";
}
$CLIENTKID = $kid;
+ write_to_file "$SESSDIR/client.pid", "$kid\n";
}
sub accept_loop () {
}
sub accept_loop () {