Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko <sergepetrenko@tarantool.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH] clear terminal state on panic
Date: Fri, 29 Nov 2019 15:20:16 +0300	[thread overview]
Message-ID: <EF522B5B-E336-4BA9-8C6B-08D8DE38D0C3@tarantool.org> (raw)
In-Reply-To: <20191129111544.GD19879@uranus>


> 29 нояб. 2019 г., в 14:15, Cyrill Gorcunov <gorcunov@gmail.com> написал(а):
> 
> On Fri, Nov 29, 2019 at 02:06:56PM +0300, Serge Petrenko wrote:
>> Hi! Thanks for your replies!
>> 
> 
> I meant different, something like
> 
> void
> tarantool_atexit(void)
> {
> 	/*
> 	 * Terminal settings might be screwed
> 	 * when exit on panic, restore the
> 	 * normal one.
> 	 */
> 	free_rl_state(void);
> }
> 
> ...
> 	at_exit(tarantool_atexit);
> 
> 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 «as_is» previously.
I mean

tarantool_free(void)
{
	/* Other cleanup routines */
	if (isatty(…)) {
		/* Clean rl state. */
	}
	/* Other cleanup routines */
}

But no problem, here’s the incremental diff
 
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()
 }
 
 void
-tarantool_atexit(void)
+free_rl_state(void)
 {
-       /* Same checks as in tarantool_free() */
-       if (getpid() != 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)
        }
 }
 
+void
+tarantool_atexit(void)
+{
+       /* Same checks as in tarantool_free() */
+       if (getpid() != master_pid)
+               return;
+
+       if (!cord_is_main())
+               return;
+
+       free_rl_state();
+}
+
 void
 tarantool_free(void)
 {


--
Serge Petrenko
sergepetrenko@tarantool.org

  reply	other threads:[~2019-11-29 12:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 15:15 Serge Petrenko
2019-11-26 20:56 ` Konstantin Osipov
2019-11-27 16:07   ` Cyrill Gorcunov
2019-11-27 21:51     ` Konstantin Osipov
2019-11-27 22:31       ` Cyrill Gorcunov
2019-11-29 11:06         ` Serge Petrenko
2019-11-29 11:15           ` Cyrill Gorcunov
2019-11-29 12:20             ` Serge Petrenko [this message]
2019-11-29 13:00               ` Cyrill Gorcunov
2019-11-29 14:53                 ` Konstantin Osipov
2019-12-10 14:03 ` Kirill Yukhin
2019-12-23 14:29   ` Alexander Turenko
2020-01-13 11:14     ` Alexander Turenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EF522B5B-E336-4BA9-8C6B-08D8DE38D0C3@tarantool.org \
    --to=sergepetrenko@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] clear terminal state on panic' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox