From 84f2f14cb146e76793a6e54ebc4c1f6a4981556e Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Mon, 19 Jul 2004 06:21:34 +0000 Subject: code factorization, do not use system() but fork() and exec() since we don't want to wait the command to return --- perl-install/standalone/net_monitor | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'perl-install/standalone/net_monitor') diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor index 91a896e28..2ccd8d040 100755 --- a/perl-install/standalone/net_monitor +++ b/perl-install/standalone/net_monitor @@ -41,8 +41,8 @@ my $disconnect = "@ARGV" =~ /--disconnect/; my ($default_intf) = "@ARGV" =~ /--defaultintf (\w+)/; if ($force) { - $connect and system("/etc/sysconfig/network-scripts/net_cnx_up"); - $disconnect and system("/etc/sysconfig/network-scripts/net_cnx_down"); + $connect and start_connection(); + $disconnect and stop_connection(); $connect = $disconnect = 0; } $quiet and exit(0); @@ -148,6 +148,18 @@ ugtk2->exit(0); my $during_connection; my $first; +sub bg_command_as_root { + fork() or exec { 'consolehelper' } @_ or die N("consolehelper missing"); +} + +sub start_connection() { + bg_command_as_root('/sbin/ifup', $default_intf); +} + +sub stop_connection() { + bg_command_as_root('/sbin/ifdown', $default_intf); +} + sub connection() { $during_connection = 1; my $wasconnected = $isconnected; @@ -222,8 +234,11 @@ sub connection() { gtkflush(); - # ergh, our integrist common::system can't lie on the program name :-/ - CORE::system { 'consolehelper' } ($wasconnected == 1 ? '/sbin/ifdown' : '/sbin/ifup', $default_intf) or die N("consolehelper missing"); + if ($wasconnected == 1) { + stop_connection(); + } else { + start_connection(); + } } sub graph_window_width() { $width - $left_border } -- cgit v1.2.1