added -d debug option for some small debug output

This commit is contained in:
duncan_ferguson 2004-04-28 08:28:14 +00:00
parent d107713209
commit 0ef5aa0ff2
2 changed files with 36 additions and 3 deletions

View file

@ -66,7 +66,7 @@ use Fcntl;
use Getopt::Std;
my %options;
getopts('x:y:z:', \%options);
getopts('x:y:z:d', \%options);
unless ($ENV{TERM}) {
$ENV{TERM} = 'xterm';
@ -84,6 +84,13 @@ if($options{x})
my $TIOCSTI=$options{y};
my $KILLOFF=$options{z};
if($options{d})
{
print "TIOCSTI=$TIOCSTI\n";
print "KILLOFF=$KILLOFF\n";
print "pipe=$options{x}\n";
}
my $pid=fork();
if(!defined($pid))
@ -129,8 +136,10 @@ if($options{x})
{
while(read($READER,my $char,1))
{
print "Received:$char:\n" if ($options{d});
last OUTTER if(ord($char) == $KILLOFF);
print "Pipe removed\n" if ($options{d} && ! -p $options{x});
last if(! -p $options{x});
unless(ioctl(STDIN,$TIOCSTI,$char))
@ -145,7 +154,10 @@ if($options{x})
last unless(kill(0,$pid));
}
}
print "Killing $pid\n" if($options{d});
kill(9,$pid) if (kill(0,$pid));
print "Removing pipe\n" if($options{d} && -p $options{x});
unlink($options{x}) if(-p $options{x});
exit;
}
@ -157,6 +169,9 @@ if($options{x})
############################################################################
# $Log$
# Revision 1.2 2004/04/28 08:28:14 duncan_ferguson
# added -d debug option for some small debug output
#
# Revision 1.1 2004/04/20 12:44:29 duncan_ferguson
# Code split off from cssh version 2.7 in attempt to speed up cx's
#

View file

@ -95,7 +95,7 @@ use Getopt::Std; # command line parsing, incase someone uses -v or -h
my %options;
# NOTE - option x is hidden and should never be called directly
getopts('x:l:hvncgst:T:', \%options);
getopts('x:l:hdvncgst:T:', \%options);
my $TIOCSTI = "";
@ -600,8 +600,11 @@ sub open_windows
my $KILLOFF=KILLOFF();
my $debug="";
$debug="-d" if($options{d});
# Start up the terminal via ourselves so the pipes are in place
exec("$user_config{'default.terminal'} $user_config{'default.terminal_options'} $place -title '$method:$serv' -e $FindBin::Bin/cchp -x $servers{$serv_name}[2] -y $TIOCSTI -z $KILLOFF $path_method $serv") or warn("Could not exec session to $serv: $! ");
exec("$user_config{'default.terminal'} $user_config{'default.terminal_options'} $place -title '$method:$serv' -e $FindBin::Bin/cchp $debug -x $servers{$serv_name}[2] -y $TIOCSTI -z $KILLOFF $path_method $serv") or warn("Could not exec session to $serv: $! ");
} else {
# parent => fork return process id of child
@ -626,6 +629,17 @@ sub open_windows
}
}
if($options{d})
{
foreach (keys(%servers))
{
foreach my $i (0..3)
{
print "servers{$_}[$i]=$servers{$_}[$i]\n";
}
}
}
change_title_number();
$mw->configure(-menu=>my $mw_mb=$mw->Menu);
@ -837,6 +851,7 @@ sub send_character {
foreach (keys(%servers))
{
send_character_to_server($_,$char);
print "Sending :$char: to $_\n";
}
$entrytext="";
}
@ -1394,6 +1409,9 @@ L<Config::Simple>
# Moved to sf.net cvs
#
# $Log$
# Revision 2.10 2004/04/28 08:28:14 duncan_ferguson
# added -d debug option for some small debug output
#
# Revision 2.9 2004/04/20 15:51:50 duncan_ferguson
# Fix bug better for when not using -g
#