X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=perl%2FExtMsg.pm;h=b39637d10e2af6f243eb580a6cbd814041ff24a1;hb=07b08c6f048732431ae45b34463387f17d68b823;hp=6ea47a516b06f69d9a43f74681cb0b8423855a04;hpb=15ee0303d77c205e68144dfd8d8a4e0110bbe5ea;p=spider.git diff --git a/perl/ExtMsg.pm b/perl/ExtMsg.pm index 6ea47a51..b39637d1 100644 --- a/perl/ExtMsg.pm +++ b/perl/ExtMsg.pm @@ -19,6 +19,7 @@ use DXUtil; use DXDebug; use IO::File; use IO::Socket; +use IPC::Open2; use vars qw(@ISA $deftimeout); @@ -58,7 +59,7 @@ sub dequeue my $conn = shift; my $msg; - if ($conn->{sort} eq 'ax25' && exists $conn->{msg}) { + if ($conn->{csort} eq 'ax25' && exists $conn->{msg}) { $conn->{msg} =~ s/\cM/\cJ/g; } if ($conn->{state} eq 'WC') { @@ -210,29 +211,19 @@ sub _doconnect 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 $!"); + $conn->{sock} = new IO::File; + if ($conn->{sock}) { + my $outfd = fileno($conn->{sock}); + my $out = new IO::File ">&$outfd"; + if ($conn->{pid} = open2($conn->{sock}, $out, $line)) { + $conn->{csort} = $sort; + $conn->{lineend} = "\cM" if $sort eq 'ax25'; + dbg('connect', "started $line"); + } else { + dbg('connect', "can't start $line $!"); } - dbg('connect', "program $sort $line started"); - $conn->{pid} = $pid; - $conn->{sort} = $sort; - $conn->{lineend} = "\cM" if $sort eq 'ax25'; } else { - dbg('connect', "can't $sort fork for $line $!"); + dbg('connect', "can't start $line $!"); } } else { dbg('err', "invalid type of connection ($sort)");