1. Crossed fingers, got rid of the instabilities caused by execing programs
[spider.git] / cmd / connect.pl
index 7fb3b7f4cc40789039ad6186e862abb4e9637bc7..df9a42389c73dc38400c0b8f4b12dd3904855da0 100644 (file)
@@ -3,8 +3,12 @@
 #
 my $self = shift;
 my $call = uc shift;
-return (0) if $self->priv < 9;
-return (1, $self->msg('already', $call)) if DXChannel::get($call);
+my $lccall = lc $call;
+
+return (0) if $self->priv < 8;
+return (1, $self->msg('e6')) unless $call gt ' ';
+return (1, $self->msg('already', $call)) if DXChannel->get($call);
+return (1, $self->msg('conscript', $lccall)) unless -e "$main::root/connect/$lccall";
 
 my $prog = "$main::root/local/client.pl";
 $prog = "$main::root/perl/client.pl" if ! -e $prog;
@@ -12,9 +16,16 @@ $prog = "$main::root/perl/client.pl" if ! -e $prog;
 my $pid = fork();
 if (defined $pid) {
        if (!$pid) {
-               # in child
+               # in child, unset warnings, disable debugging and general clean up from us
+               $^W = 0;
+               $SIG{HUP} = 'IGNORE';
+               eval "{ package DB; sub DB {} }";
+               alarm(0);
+               DXChannel::closeall();
+               $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT';
                exec $prog, $call, 'connect';
        } else {
+               sleep(1);    # do a coordination
                return(1, $self->msg('constart', $call));
        }
 }