01Apr01=======================================================================
1. changed agwrestart semantics. You need to use main::agwrestart() in your
crontabs rather than AGWMsg::init();
+2. try to thread winclient.pl for MSWin32.
31Mar01=======================================================================
1. added agwrestart command
2. add Iains Windoze installation manual (g0vgs)
use IO::Socket;
use DXVars;
use IO::File;
+use Config;
#
# deal with args
exit(0);
}
-# Fork one in / one out .....
+STDOUT->autoflush(1);
+$handle->autoflush(1);
+print $handle "A$call|local\n";
+
+# Fork or thread one in / one out .....
my $childpid;
-die "can't fork: $!" unless defined($childpid = fork());
+my $t;
+if ($Config{usethreads}) {
+ require Thread;
+# print "Using Thread Method\n";
+ $t = Thread->new(\&dostdin);
+ donetwork();
+ $t->join;
+ kill(-1, $$);
+} else {
+# print "Using Fork Method\n";
+ die "can't fork: $!" unless defined($childpid = fork());
+ if ($childpid) {
+ donetwork();
+ kill 'TERM', $childpid;
+ } else {
+ dostdin();
+ }
+}
+exit 0;
+
-# the communication .....
-if ($childpid) {
+sub donetwork
+{
my ($lastend, $end) = ("\n", "\n");
- STDOUT->autoflush(1);
while (defined (my $msg = <$handle>)) {
my ($sort, $call, $line) = $msg =~ /^(\w)([^\|]+)\|(.*)$/;
next unless defined $sort;
$line =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
if ($sort eq 'Z') {
- kill 'TERM', $childpid;
- exit(0);
+ return;
} elsif ($sort eq 'E' || $sort eq 'B') {
;
} else {
print $begin . $line . $end;
}
}
- kill 'TERM', $childpid;
-} else {
- $handle->autoflush(1);
- print $handle "A$call|local\n";
+}
+
+sub dostdin
+{
while (defined (my $line = <STDIN>)) {
print $handle "I$call|$line\n";
+ if ($t && ($line =~ /^b/i || $line =~ /^q/i)) {
+ return;
+ }
}
}
-exit 0;
+