zsh-workers
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: A serious bug in execution – where to debug?
Date: Tue, 30 Jul 2019 21:23:53 +0200	[thread overview]
Message-ID: <CAN=4vMqhVGbZDUd59aHkqh90U2+fTriEz741t1dTQQ_vSqbFsw@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVBeVzKHeeq_kFfbMhx7iF-nBnk2O4dSJVtXCoZW=517pQ@mail.gmail.com>

On Tue, Jul 30, 2019 at 8:53 PM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> On Tue, 30 Jul 2019 at 20:22, Roman Perepelitsa
> <roman.perepelitsa@gmail.com> wrote:
> >
> > Do you think it's possible to implement clean shutdown and reentrant
> > initialization for a piece of code as blackbox?
>
> What do you mean exactly? As a blackbox - as a regular, repeatable method?

In order to implement clean shutdown for a piece of code with
non-trivial capabilities you have to rely on its implementation
details. You cannot implement generic clean shutdown that will work
with any code.

Here's an example. Suppose a plugin you are monitoring spawns a
process. Should you kill it when you unload the plugin? It depends. If
this plugin spawns a process every time it is loaded and kills it
every time you call its public `shutdown` function, then you should
probably kill it to avoid leaking processes. You don't want to have a
horde of stray processes if the plugin is loaded and unloaded multiple
times. On the other hand, if this plugin spawns a one-per-user daemon
(could also be one-per-machine), then another shell might already be
using it, and if you kill the daemon when the plugin is unloaded in
one shell, you can break that same plugin in another shell. Plugins
don't expect that their internal processes will be randomly killed,
files randomly deleted and internal variables randomly unset, so if
you start doing it, things will break. To implement clean shutdown in
this case, you need to check whether this plugin is the last instance
for this user/machine and only then kill the daemon. In other words,
in both cases you need to implement the same logic the plugin already
implements in its shutdown routine. Once you implement it, you have to
keep it in sync with internal implementation changes of the plugin.

Roman.

  reply	other threads:[~2019-07-30 20:59 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 17:00 Sebastian Gniazdowski
2019-07-30 17:05 ` Sebastian Gniazdowski
2019-07-30 17:41 ` Roman Perepelitsa
2019-07-30 17:55   ` Sebastian Gniazdowski
2019-07-30 18:12     ` Roman Perepelitsa
2019-07-30 18:16       ` Sebastian Gniazdowski
2019-07-30 18:22         ` Roman Perepelitsa
2019-07-30 18:53           ` Sebastian Gniazdowski
2019-07-30 19:23             ` Roman Perepelitsa [this message]
2019-07-30 19:34               ` Sebastian Gniazdowski
2019-07-30 19:41                 ` Roman Perepelitsa
2019-07-30 19:59                   ` Sebastian Gniazdowski
2019-07-30 20:08                     ` Roman Perepelitsa
2019-07-30 20:38                       ` Sebastian Gniazdowski
2019-07-30 18:27 ` Bart Schaefer
2019-07-30 18:46   ` Sebastian Gniazdowski
2019-07-30 21:02     ` Roman Perepelitsa
2019-07-30 21:38       ` Sebastian Gniazdowski
2019-07-30 21:45         ` Roman Perepelitsa
2019-07-30 21:54           ` Sebastian Gniazdowski
2019-07-30 22:11             ` Roman Perepelitsa
2019-07-30 22:18           ` Daniel Shahaf
2019-07-30 22:32             ` Roman Perepelitsa
2019-07-31  1:30               ` Sebastian Gniazdowski
2019-07-31  7:23                 ` Roman Perepelitsa
2019-07-31 11:41                   ` Sebastian Gniazdowski
2019-07-31 12:40                     ` Roman Perepelitsa
2019-07-31 13:10                       ` Sebastian Gniazdowski
2019-07-31 13:34                         ` Roman Perepelitsa
2019-07-31 13:40                           ` Sebastian Gniazdowski
2019-07-31 14:11                             ` Roman Perepelitsa
2019-07-31 17:56                               ` Sebastian Gniazdowski
2019-07-31  1:42               ` Bart Schaefer

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='CAN=4vMqhVGbZDUd59aHkqh90U2+fTriEz741t1dTQQ_vSqbFsw@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=sgniazdowski@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).