summaryrefslogtreecommitdiffstats
path: root/perl-install/network/tools.pm
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2001-10-09 11:15:53 +0000
committerdamien <damien@mandriva.com>2001-10-09 11:15:53 +0000
commit7befd0e218e67479b59a9867d6fad0f17714db42 (patch)
treeb3846c68e8e9c9089745e58b6589e4a04d713c6f /perl-install/network/tools.pm
parent0ee135141e9cadcb581c0caf1c9e7d44d57aaa63 (diff)
downloaddrakx-7befd0e218e67479b59a9867d6fad0f17714db42.tar
drakx-7befd0e218e67479b59a9867d6fad0f17714db42.tar.gz
drakx-7befd0e218e67479b59a9867d6fad0f17714db42.tar.bz2
drakx-7befd0e218e67479b59a9867d6fad0f17714db42.tar.xz
drakx-7befd0e218e67479b59a9867d6fad0f17714db42.zip
connection test is now in background, corrects the interface freeze problem
Diffstat (limited to 'perl-install/network/tools.pm')
-rw-r--r--perl-install/network/tools.pm42
1 files changed, 40 insertions, 2 deletions
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm
index 1d033031e..4fdab586a 100644
--- a/perl-install/network/tools.pm
+++ b/perl-install/network/tools.pm
@@ -6,7 +6,7 @@ use vars qw(@ISA @EXPORT);
use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_prog $connect_file $disconnect_file);
@ISA = qw(Exporter);
-@EXPORT = qw(write_cnx_script write_secret_backend write_initscript ask_connect_now connect_backend disconnect_backend read_providers_backend ask_info2 type2interface connected disconnected);
+@EXPORT = qw(write_cnx_script write_secret_backend write_initscript ask_connect_now connect_backend disconnect_backend read_providers_backend ask_info2 type2interface connected connected_bg connected2 disconnected);
@EXPORT_OK = qw($in);
sub write_cnx_script {
@@ -112,7 +112,43 @@ sub type2interface {
[ lan => 'eth']);
}
-sub connected { gethostbyname("www.mandrakesoft.com") ? 1 : 0 }
+sub connected { gethostbyname("mandrakesoft.com") ? 1 : 0 }
+
+my $kid_pipe;
+sub connected_bg {
+ my ($ref) = @_;
+ if (defined $kid_pipe) {
+ print "GGGGGGGGG\n";
+ local *F;
+ *F = *$kid_pipe;
+ fcntl(F, F_SETFL, O_NONBLOCK) or die "can't fcntl F_SETFL: $!";
+ my $a;
+ if ($a = <F> ) {
+ print "gooood\n";
+ chomp $a;
+ close($kid_pipe) || warn "kid exited $?";
+ undef $kid_pipe;
+ $a eq '1' and $$ref = 1;
+ $a eq '0' and $$ref = 0;
+ }
+ } else {
+ print "BBBBBBBBB\n";
+ $kid_pipe = connected2();
+ }
+ 1;
+}
+
+sub connected2 {
+ my $pid = open(KID_TO_READ, "-|");
+ if ($pid) { # parent
+ return \*KID_TO_READ;
+ } else { # child
+ ($EUID, $EGID) = ($UID, $GID); # suid only
+ my $a = gethostbyname("mandrakesoft.com") ? 1 : 0;
+ print "$a\n";
+ c::_exit(0);
+ }
+}
sub disconnected { }
@@ -169,3 +205,5 @@ exit 0
'0.d/K11internet', '1.d/K11internet', '2.d/K11internet', '3.d/S89internet', '5.d/S89internet', '6.d/K11internet';
};
}
+
+1;