diff options
author | Olivier Blin <oblin@mandriva.org> | 2004-07-19 06:21:34 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2004-07-19 06:21:34 +0000 |
commit | 84f2f14cb146e76793a6e54ebc4c1f6a4981556e (patch) | |
tree | 6f16fc351392a03647ec37ff7d158415e10bc14d | |
parent | ec8abeab07f8a074e7a6969744e85dc74fd1d99e (diff) | |
download | drakx-84f2f14cb146e76793a6e54ebc4c1f6a4981556e.tar drakx-84f2f14cb146e76793a6e54ebc4c1f6a4981556e.tar.gz drakx-84f2f14cb146e76793a6e54ebc4c1f6a4981556e.tar.bz2 drakx-84f2f14cb146e76793a6e54ebc4c1f6a4981556e.tar.xz drakx-84f2f14cb146e76793a6e54ebc4c1f6a4981556e.zip |
code factorization, do not use system() but fork() and exec() since we don't
want to wait the command to return
-rwxr-xr-x | perl-install/standalone/net_monitor | 23 |
1 files changed, 19 insertions, 4 deletions
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 } |