From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 860c96b8 for ; Tue, 30 Jul 2019 20:59:51 +0000 (UTC) Received: (qmail 21267 invoked by alias); 30 Jul 2019 19:24:42 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44603 Received: (qmail 22109 invoked by uid 1010); 30 Jul 2019 19:24:41 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f44.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25524. spamassassin: 3.4.2. Clear:RC:0(209.85.166.44):SA:0(-2.0/5.0):. Processed in 3.622082 secs); 30 Jul 2019 19:24:41 -0000 X-Envelope-From: roman.perepelitsa@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.44 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KI/1+aBdHE4qd9DBCsQ2FiBzGckSJkwUkfguyjsqmlk=; b=BL3QcE9JrTC0/fRs19+G/ysBX0NN88gjBfAu4VesL+R8oVNS9h9M27AQawzUzNZ2R7 umAfhPnZSuvTG6P5UVpIP7JSpeWem/6aGWv+HEu6LhLstEnylkv8xP+EegMY/+YCPE/l N//Tt+e/lAknDTTvOOsAyuuIxJSgeHdtxozKFrEfTyUGAS+kSZ+vprkHa0xu4bHXXU+F uDpuN/DSeLJ+lzqYPru/PIdFxWbw3QgX9qkNKzv5NOJhqFcaQ7oLrdWw8Rxofz4YoEew ov8z93OnYmmcUbwOertdsQypyKq4SwJrwaQbM4pLPZ7t1H4P9i77rjIFyRQNB3wrPfTl 30BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KI/1+aBdHE4qd9DBCsQ2FiBzGckSJkwUkfguyjsqmlk=; b=PQyrpbvt4Z5gQUGnbeRF7dIDF9t9fz03GcR8Tqypwp5e84RewPtjQvnok+COCmjVJC C5HbmwRX38fGDPG1IxhfcstKd3sT/jO3RYWTWg7FU5/9MH+70IAkrcF/KJ/tGqtjREkO DDDQdcgq/AJ7ilChOK2jCFLvIOUwrPOmtp5Y/OTXsryTOXk9kGl1xLTdrKZKoIu6YUBz VMheWBq8h/RS225cuI0T5GwvFSosD2CmUaHwOM+z1B/gjQD5bzsffDDFzVSbI+6+ygii 0KsTMFna8ov/VaA/4mSS+3XhaNt1GWUrzHE70lVzR9RHPI4mRHaC1SV2ZDRJtqId5CL9 7tDg== X-Gm-Message-State: APjAAAVerfSKCVxKARsAoxiCi/HZ6xVEizYVuJ8CykD6LBAfza66M/sr egNfsQMn8jTAGTBhFEoBeL0IHhTwxtHuyEw/atc= X-Google-Smtp-Source: APXvYqzp8DCTmRHRfp7fuM9PV7pDtPjFekRvM50DJioXNXMLbLcsC9PuC3DC0nVBrxf9J0hJ8rP3Nxz/kX2bhg4Kmeg= X-Received: by 2002:a02:aa1d:: with SMTP id r29mr50094594jam.127.1564514645236; Tue, 30 Jul 2019 12:24:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Tue, 30 Jul 2019 21:23:53 +0200 Message-ID: Subject: =?UTF-8?Q?Re=3A_A_serious_bug_in_execution_=E2=80=93_where_to_debug=3F?= To: Sebastian Gniazdowski Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" On Tue, Jul 30, 2019 at 8:53 PM Sebastian Gniazdowski wrote: > > On Tue, 30 Jul 2019 at 20:22, Roman Perepelitsa > 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.