From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 8F06C46970F for ; Fri, 29 Nov 2019 14:06:58 +0300 (MSK) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) From: Serge Petrenko In-Reply-To: <20191127223131.GG2472@uranus> Date: Fri, 29 Nov 2019 14:06:56 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <48080BBC-71D6-48A7-9330-4D76B154E7CF@tarantool.org> References: <20191126151557.25754-1-sergepetrenko@tarantool.org> <20191126205620.GC23422@atlas> <20191127160751.GF2472@uranus> <20191127215147.GB31812@atlas> <20191127223131.GG2472@uranus> Subject: Re: [Tarantool-patches] [PATCH] clear terminal state on panic List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov , Konstantin Osipov Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for your replies! Fixed: diff --git a/src/main.cc b/src/main.cc index 014958a17..a1572b81e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -589,7 +589,7 @@ load_cfg() } =20 void -free_rl_state(void) +tarantool_atexit(void) { /* Same checks as in tarantool_free() */ if (getpid() !=3D master_pid) @@ -848,7 +848,14 @@ main(int argc, char **argv) trigger_create(&break_loop_trigger, break_loop, NULL, = NULL); trigger_add(&box_on_shutdown, &break_loop_trigger); =20 - atexit(free_rl_state); + /* + * The call to tarantool_free() below, thanks to + * on_shutdown triggers, works all the time + * except when we panic. So leave the ever- + * necessary cleanups in atexit handler, which + * is executed always. + */ + atexit(tarantool_atexit); =20 if (!loop()) panic("%s", "can't init event loop"); -- Serge Petrenko sergepetrenko@tarantool.org > 28 =D0=BD=D0=BE=D1=8F=D0=B1. 2019 =D0=B3., =D0=B2 1:31, Cyrill = Gorcunov =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0= =B0): >=20 > On Thu, Nov 28, 2019 at 12:51:47AM +0300, Konstantin Osipov wrote: >>>=20 >>> Should not we rather provide some tarantool_atexit() helper >>> from where we would call other cleanup and etc routines? >>> We already have tarantool_atfork() hook. Not a big deal >>> but while the code in question is being modified anyway. >>=20 >> Why not, still the exit procedure is complicated because of >> on_shutdown triggers, so it's important that if there are changes >> to it, they are documented in the code, not in cs comments. >=20 > Yes, putting comment into the code why we're to restore the > terminal settings on panic is quite important.