use DXDebug;
use IO::File;
use IO::Socket;
+use IPC::Open3;
use vars qw(@ISA $deftimeout);
dbg('connect', $msg) unless $conn->{state} eq 'C';
$msg =~ s/\xff\xfa.*\xff\xf0|\xff[\xf0-\xfe].//g; # remove telnet options
- $msg =~ s/[\x00-\x08\x0a-\x1f\x80-\x9f]/./g; # immutable CSI sequence + control characters
+ $msg =~ s/[\x00-\x08\x0a-\x19\x1b-\x1f\x80-\x9f]/./g; # immutable CSI sequence + control characters
if ($conn->{state} eq 'C') {
&{$conn->{rproc}}($conn, "I$conn->{call}|$msg");
dbg('connect', "***Connect Failed to $host $port $!");
}
} elsif ($sort eq 'ax25' || $sort eq 'prog') {
- my $pid = fork();
- if (defined $pid) {
- if (!$pid) {
- # in child, unset warnings, disable debugging and general clean up from us
- $^W = 0;
- eval "{ package DB; sub DB {} }";
- DXChannel::closeall();
- for (@main::listeners) {
- $_->close_server;
- }
- unless ($^O =~ /^MS/) {
- $SIG{HUP} = 'IGNORE';
- $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT';
- alarm(0);
- }
- exec "$line" or dbg('cron', "exec '$line' failed $!");
- }
- dbg('connect', "program $sort $line started");
- $conn->{pid} = $pid;
+ my $sock = new IO::Socket::INET;
+ local *H;
+ my $wrt = \*H;
+
+ if ($conn->{pid} = open3("<&$sock", ">&$sock", '', $line)) {
+ $conn->{sock} = $sock;
$conn->{csort} = $sort;
$conn->{lineend} = "\cM" if $sort eq 'ax25';
+ dbg('connect', "started pid: $conn->{pid} as $line");
} else {
- dbg('connect', "can't $sort fork for $line $!");
+ dbg('connect', "can't start $line $!");
}
} else {
dbg('err', "invalid type of connection ($sort)");