1. Crossed fingers, got rid of the instabilities caused by execing programs
[spider.git] / cmd / connect.pl
1 #
2 # connect a cluster station
3 #
4 my $self = shift;
5 my $call = uc shift;
6 my $lccall = lc $call;
7
8 return (0) if $self->priv < 8;
9 return (1, $self->msg('e6')) unless $call gt ' ';
10 return (1, $self->msg('already', $call)) if DXChannel->get($call);
11 return (1, $self->msg('conscript', $lccall)) unless -e "$main::root/connect/$lccall";
12
13 my $prog = "$main::root/local/client.pl";
14 $prog = "$main::root/perl/client.pl" if ! -e $prog;
15
16 my $pid = fork();
17 if (defined $pid) {
18         if (!$pid) {
19                 # in child, unset warnings, disable debugging and general clean up from us
20                 $^W = 0;
21                 $SIG{HUP} = 'IGNORE';
22                 eval "{ package DB; sub DB {} }";
23                 alarm(0);
24                 DXChannel::closeall();
25                 $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT';
26                 exec $prog, $call, 'connect';
27         } else {
28                 sleep(1);    # do a coordination
29                 return(1, $self->msg('constart', $call));
30         }
31 }
32 return (0, $self->msg('confail', $call, $!))
33
34
35