From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (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 A120246970F for ; Fri, 29 Nov 2019 15:20:17 +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: <20191129111544.GD19879@uranus> Date: Fri, 29 Nov 2019 15:20:16 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20191126151557.25754-1-sergepetrenko@tarantool.org> <20191126205620.GC23422@atlas> <20191127160751.GF2472@uranus> <20191127215147.GB31812@atlas> <20191127223131.GG2472@uranus> <48080BBC-71D6-48A7-9330-4D76B154E7CF@tarantool.org> <20191129111544.GD19879@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 Cc: tarantool-patches@dev.tarantool.org > 29 =D0=BD=D0=BE=D1=8F=D0=B1. 2019 =D0=B3., =D0=B2 14:15, Cyrill = Gorcunov =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0= =B0): >=20 > On Fri, Nov 29, 2019 at 02:06:56PM +0300, Serge Petrenko wrote: >> Hi! Thanks for your replies! >>=20 >=20 > I meant different, something like >=20 > void > tarantool_atexit(void) > { > /* > * Terminal settings might be screwed > * when exit on panic, restore the > * normal one. > */ > free_rl_state(void); > } >=20 > ... > at_exit(tarantool_atexit); >=20 > This will allow us to extend tarantool_atexit() > with other cleanup routines if we need to. > Sounds reasonable? Well, we can append other routines to tarantool_atexit anyway. I wrapped the code into free_rl_state() in the previous patch, but it was inlined into tarantool_free =C2=ABas_is=C2=BB previously. I mean tarantool_free(void) { /* Other cleanup routines */ if (isatty(=E2=80=A6)) { /* Clean rl state. */ } /* Other cleanup routines */ } But no problem, here=E2=80=99s the incremental diff =20 diff --git a/src/main.cc b/src/main.cc index a1572b81e..e674d85b1 100644 --- a/src/main.cc +++ b/src/main.cc @@ -589,15 +589,8 @@ load_cfg() } =20 void -tarantool_atexit(void) +free_rl_state(void) { - /* Same checks as in tarantool_free() */ - if (getpid() !=3D master_pid) - return; - - if (!cord_is_main()) - return; - /* tarantool_lua_free() was formerly reponsible for terminal = reset, * but it is no longer called */ @@ -610,6 +603,19 @@ tarantool_atexit(void) } } =20 +void +tarantool_atexit(void) +{ + /* Same checks as in tarantool_free() */ + if (getpid() !=3D master_pid) + return; + + if (!cord_is_main()) + return; + + free_rl_state(); +} + void tarantool_free(void) { -- Serge Petrenko sergepetrenko@tarantool.org