From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 59B77A1DE1 for ; Fri, 16 Jun 2023 12:57:45 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3A8E1318AD for ; Fri, 16 Jun 2023 12:57:45 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 16 Jun 2023 12:57:44 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6E57B45C06 for ; Fri, 16 Jun 2023 12:57:44 +0200 (CEST) From: Maximiliano Sandoval To: pve-devel@lists.proxmox.com Date: Fri, 16 Jun 2023 12:57:42 +0200 Message-Id: <20230616105743.105209-2-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616105743.105209-1-m.sandoval@proxmox.com> References: <20230616105743.105209-1-m.sandoval@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH installer 1/2] exit process gracefully X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jun 2023 10:57:45 -0000 We make sure that all exit calls quit the Glib main loop and child processes. Signed-off-by: Maximiliano Sandoval --- proxinstall | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/proxinstall b/proxinstall index 2f63679..701133b 100755 --- a/proxinstall +++ b/proxinstall @@ -235,6 +235,18 @@ compatibility_level = 2 _EOD +sub app_quit { + my ($exit_code) = @_; + + Gtk3->main_quit() if Gtk3->main_level() > 0; + + # reap left over zombie processes + while ((my $child = waitpid(-1, POSIX::WNOHANG)) > 0) { + print "reaped child $child\n"; + } + exit($exit_code); +} + sub detect_country { print "trying to detect country...\n"; my $cpid = open2(my $TRACEROUTE_FH, undef, "traceroute -N 1 -q 1 -n 8.8.8.8"); @@ -491,7 +503,7 @@ sub ask_existing_vg_rename_or_abort { die "could not rename VG from '$vg->{pvs}' ($vg_uuid) to '$new_vgname'!\n"; } } else { - set_next("_Reboot", sub { exit (0); } ); + set_next("_Reboot", sub { app_quit(0); } ); display_html("fail.htm"); die "Cancled installation by user, due to already existing volume group '$vgname'\n"; } @@ -1529,7 +1541,7 @@ sub create_main_window { my $abort = Gtk3::Button->new('_Abort'); $abort->set_can_focus(0); $cmdbox->pack_start($abort, 0, 0, 10); - $abort->signal_connect(clicked => sub { exit (-1); }); + $abort->signal_connect(clicked => sub { app_quit(-1); }); my $vbox2 = Gtk3::VBox->new(0, 0); $hbox->add($vbox2); @@ -2968,7 +2980,7 @@ sub create_extract_view { $next->set_sensitive(1); - set_next("_Reboot", sub { exit (0); } ); + set_next("_Reboot", sub { app_quit(0); } ); if ($err) { display_html("fail.htm"); @@ -2983,7 +2995,7 @@ sub create_extract_view { $autoreboot_seconds--; display_html("success.htm"); } else { - exit(0); + app_quit(0); } }); } @@ -3038,7 +3050,7 @@ my $initial_error = 0; print "no harddisks found\n"; $initial_error = 1; display_html("nohds.htm"); - set_next("Reboot", sub { exit(0); } ); + set_next("Reboot", sub { app_quit(0); } ); } else { foreach my $hd (@$cached_disks) { my ($disk, $devname) = @$hd; @@ -3052,16 +3064,11 @@ if (!$initial_error && (scalar keys %{ $ipconf->{ifaces} } == 0)) { print "no network interfaces found\n"; $initial_error = 1; display_html("nonics.htm"); - set_next("Reboot", sub { exit(0); } ); + set_next("Reboot", sub { app_quit(0); } ); } create_intro_view () if !$initial_error; Gtk3->main; -# reap left over zombie processes -while ((my $child = waitpid(-1, POSIX::WNOHANG)) > 0) { - print "reaped child $child\n"; -} - -exit 0; +app_quit(0); -- 2.39.2