summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni@mandriva.org>2009-10-27 11:56:58 +0000
committerEugeni Dodonov <eugeni@mandriva.org>2009-10-27 11:56:58 +0000
commita09384d14365fc46eb8c91b0173bb5de824875f6 (patch)
tree304c08d34e2c501eccfe744659a9e898e5976e12
parentc0d9e40c3fb3b8dd5578e27bc7ad0c840fad0356 (diff)
downloaddrakx-net-a09384d14365fc46eb8c91b0173bb5de824875f6.tar
drakx-net-a09384d14365fc46eb8c91b0173bb5de824875f6.tar.gz
drakx-net-a09384d14365fc46eb8c91b0173bb5de824875f6.tar.bz2
drakx-net-a09384d14365fc46eb8c91b0173bb5de824875f6.tar.xz
drakx-net-a09384d14365fc46eb8c91b0173bb5de824875f6.zip
properly take care of child processes
-rwxr-xr-xbin/net_applet62
1 files changed, 20 insertions, 42 deletions
diff --git a/bin/net_applet b/bin/net_applet
index 8ededfd..fc68d70 100755
--- a/bin/net_applet
+++ b/bin/net_applet
@@ -2,6 +2,7 @@
use strict;
+use POSIX ":sys_wait_h";
use lib qw(/usr/lib/libDrakX);
# i18n: IMPORTANT: to get correct namespace (drakx-net instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakx-net' }
@@ -127,13 +128,6 @@ sub get_interface_name {
$type_name ? "$type_name ($interface)" : $interface;
}
-sub ignore_children(&) {
- my ($f) = @_;
- # do not create zombies (#20552)
- local $SIG{CHLD} = 'IGNORE';
- &$f;
-}
-
my %actions = (
'upNetwork' => { name => sub { N("Connect %s", get_interface_name($_[0])) }, launch => sub { network::tools::start_interface($_[0], 1) } },
'downNetwork' => { name => sub { N("Disconnect %s", get_interface_name($_[0])) }, launch => sub { network::tools::stop_interface($_[0], 1) } },
@@ -142,18 +136,10 @@ my %actions = (
'wireless' => { name => N("Manage wireless networks"), launch => sub { run_drakroam() } },
'drakvpn' => {
name => N("Manage VPN connections"), launch => sub {
- ignore_children {
- run_program::raw({ detach => 1 }, '/usr/sbin/drakvpn');
- };
+ run_program::raw({ detach => 1 }, '/usr/sbin/drakvpn');
},
},
- 'confNetwork' => {
- name => N("Configure Network"), launch => sub {
- ignore_children {
- system("/usr/sbin/drakconnect &");
- };
- }
- },
+ 'confNetwork' => { name => N("Configure Network"), launch => sub { system("/usr/sbin/drakconnect &") } },
'chooseInterface' => {
name => N("Watched interface"),
choices => sub { N("Auto-detect"), sort keys %{$net->{ifcfg}} },
@@ -188,11 +174,9 @@ my %actions = (
choices => sub { network::network::netprofile_list() },
choice_selected => sub { $_[0] eq $net->{PROFILE} },
launch => sub {
- ignore_children {
- require run_program;
- $net->{PROFILE} = $_[0];
- run_program::raw({ detach => 1 }, common::wrap_command_for_root('/sbin/set-netprofile', $net->{PROFILE}));
- };
+ require run_program;
+ $net->{PROFILE} = $_[0];
+ run_program::raw({ detach => 1 }, common::wrap_command_for_root('/sbin/set-netprofile', $net->{PROFILE}));
}
},
'chooseVPN' => {
@@ -204,14 +188,7 @@ my %actions = (
choice_selected => sub { $_[0]->is_started },
launch => sub { require interactive; $_[0]->is_started ? $_[0]->stop : $_[0]->start(interactive->vnew) },
},
- 'help' => {
- name => N("Help"),
- launch => sub {
- ignore_children {
- system("drakhelp --id internet-connection &");
- };
- },
- },
+ 'help' => { name => N("Help"), launch => sub { system("drakhelp --id internet-connection &") } },
'quit' => { name => N("Quit"), launch => \&mainQuit },
);
@@ -269,6 +246,15 @@ $SIG{USR1} = sub {
my @packets = eval { $network::net_applet::ifw->get_reports };
};
+# do not create zombies (#20552)
+$SIG{CHLD} = \&harvester;
+sub harvester {
+ my $pid;
+ do {
+ # we don't care about our child processes
+ $pid = waitpid(-1, &WNOHANG);
+ } while $pid > 0;
+}
Gtk2->main;
@@ -302,29 +288,21 @@ sub shouldStart() {
return getAutoStart();
}
sub run_net_monitor() {
- ignore_children {
- run_program::raw({ detach => 1 }, '/usr/bin/net_monitor', '--defaultintf', $current_interface) unless is_running('net_monitor');
- };
+ run_program::raw({ detach => 1 }, '/usr/bin/net_monitor', '--defaultintf', $current_interface) unless is_running('net_monitor');
}
sub run_netcenter() {
- ignore_children {
- run_program::raw({ detach => 1 }, '/usr/bin/draknetcenter') unless is_running('draknetcenter', 'root');
- };
+ run_program::raw({ detach => 1 }, '/usr/bin/draknetcenter') unless is_running('draknetcenter', 'root');
}
sub run_drakroam {
my ($o_ap) = @_;
- ignore_children {
- run_program::raw({ detach => 1 }, '/usr/sbin/drakroam', if_($o_ap, "--ap=$o_ap")) unless is_running('drakroam', 'root');
- };
+ run_program::raw({ detach => 1 }, '/usr/sbin/drakroam', if_($o_ap, "--ap=$o_ap")) unless is_running('drakroam', 'root');
}
sub run_drakids() {
$ifw_alert = 0;
if (is_running('drakids')) {
eval { $ifw->send_manage_request };
} else {
- ignore_children {
- run_program::raw({ detach => 1 }, '/usr/sbin/drakids');
- };
+ run_program::raw({ detach => 1 }, '/usr/sbin/drakids');
}
}
sub generate_wireless_menuitem {