From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Joris Vankerschaver Newsgroups: gmane.emacs.devel Subject: Re: Two questions about atexit cleanup in dynamic modules Date: Mon, 10 Apr 2017 18:36:05 +0100 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1144472cec8551054cd36889 X-Trace: blaine.gmane.org 1491845848 20279 195.159.176.226 (10 Apr 2017 17:37:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 10 Apr 2017 17:37:28 +0000 (UTC) Cc: emacs-devel@gnu.org To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 10 19:37:23 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxdFi-0005BU-FG for ged-emacs-devel@m.gmane.org; Mon, 10 Apr 2017 19:37:22 +0200 Original-Received: from localhost ([::1]:35656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxdFo-0003Jv-8o for ged-emacs-devel@m.gmane.org; Mon, 10 Apr 2017 13:37:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxdEb-0002Qc-3B for emacs-devel@gnu.org; Mon, 10 Apr 2017 13:36:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxdEY-0007Yg-Oy for emacs-devel@gnu.org; Mon, 10 Apr 2017 13:36:12 -0400 Original-Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:37333) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxdEY-0007X9-FF for emacs-devel@gnu.org; Mon, 10 Apr 2017 13:36:10 -0400 Original-Received: by mail-wm0-x229.google.com with SMTP id u2so43152243wmu.0 for ; Mon, 10 Apr 2017 10:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5k1L1J+rrh6fNMRS41QQ2g/Q8uhTZRk8sbIWbA5n0Mk=; b=eSo7Y6L/5ep3KfnVtjIr4GkAkEEtxyqLqERCtMtPVbhLrmKcq4UlKDHDhjtFuTrv05 clQlmZMC66bMeLYAmw865+O1PDqob/jIaPCwdcFW6hby7oZJUrK2KWVMHPiSqezjOzCI LvM5MYwHYX+nDe/vWGpuDnUHXB2ExA0fa3AJhBnwKIp7Vjb84lg5tPVCjTlbDbm8PZme 4H0lj93ena9txkCseZjfmhjIjqI8EPi3JLBcruGISNhBgYyHo7/ZQUv6f2aVbr64V234 WAGu0wkR7hSlZSUBGwA49XsYD7AkG6Z36NGCv6g6q7irBOTobwkBMsDSwrh4/9eykN+L 9n3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5k1L1J+rrh6fNMRS41QQ2g/Q8uhTZRk8sbIWbA5n0Mk=; b=Fs3NrI3F5gITMJzZezNTsjCwnPZKUQhg3rlpY6p9dSypcRl9bEbHsPbRTLT7ycZiP2 VpEOxHQ3dTuyNoRpZL3pVHRFWYTbLPIQtaC6gVsblrTT4nGiqog5iEPG3yhTkstMeCQr 4WU1qRdoWQnOJaEOfMh8eFoXkYRBHnQ2q198hv2Km4G23ywbBWu5x6HROhV2qIoY/vG4 6V8Bvex1fIV4U6QINl/D7MmzAHYMVbUBPQtwxomSXar7n73kM+c0BruYgIEqFoUzM/SK 71c5nx0nyNbkPIsq36e9IpkxeTA3bipUz9JN0rjxXOFRY9f2BqHFJrM47zJ8hxQBCMRh zWaQ== X-Gm-Message-State: AN3rC/56LyfSGuAb0Ot1q8Ja5jvsezADmPY9WrnPAFX17n52HF1amYuX Cq09jjrF+QXMUCVax9eo55Z/jE8eFw== X-Received: by 10.28.178.84 with SMTP id b81mr12035744wmf.83.1491845765692; Mon, 10 Apr 2017 10:36:05 -0700 (PDT) Original-Received: by 10.80.166.69 with HTTP; Mon, 10 Apr 2017 10:36:05 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213838 Archived-At: --001a1144472cec8551054cd36889 Content-Type: text/plain; charset=UTF-8 Dear Philipp, Many thanks for the confirmation regarding atexit, and for pointing out the kill-emacs-hook. This is exactly what I needed! With best wishes, Joris On Sat, Apr 8, 2017 at 5:38 PM, Philipp Stephani wrote: > > > Joris Vankerschaver schrieb am Fr., 7. > Apr. 2017 um 10:52 Uhr: > >> Hi all, >> >> I wrote a small Emacs dynamic module to execute Python scripts in an >> embedded >> Python interpreter (https://github.com/jvkersch/emacs-python). The main >> thing >> missing is that I would like to do some cleanup in the embedded Python >> interpreter when Emacs exits (close open files, deal with >> threads/processes, >> etc). What would be the best way to do so? >> >> 1. Can I just register an atexit handler when my module starts, or will >> that >> interfere with some Emacs internals? >> > > Unless you attempt to call Emacs functions in the atexit handler, that > should be fine. > > >> >> 2. Would it make sense to add support to the module API for a cleanup >> callback >> that is called when Emacs exits? >> > > You can already use the hook `kill-emacs-hook' as usual. That's especially > useful if your cleanup needs to interact with Emacs. > --001a1144472cec8551054cd36889 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Dear Philipp,

Many thanks for the confi= rmation regarding atexit, and for pointing out the kill-emacs-hook. This is= exactly what I needed!

With best wishes,
Joris=

On Sa= t, Apr 8, 2017 at 5:38 PM, Philipp Stephani <p.stephani2@gmail.com> wrote:

Joris Van= kerschaver <joris.vankerschaver@gmail.com> schrieb am Fr., 7. Apr. 2= 017 um 10:52=C2=A0Uhr:
Hi all,

I wrote a small Emacs dynamic module to execute Pyth= on scripts in an embedded
Python interpreter (https://github.c= om/jvkersch/emacs-python). The main thing
missing is that I would like to do some cleanup = in the embedded Python
i= nterpreter when Emacs exits (close open files, deal with threads/processes,=
etc). What would be the= best way to do so?

1. Can I just register an atexit handler when my module s= tarts, or will that
inte= rfere with some Emacs internals?

Unless you attempt to call Emacs functions in the atexit handler, = that should be fine.
=C2=A0
<= div class=3D"m_8432415359960002293gmail_msg">
2. Would= it make sense to add support to the module API for a cleanup callback
that is called when Emacs ex= its?

You can already use= the hook `kill-emacs-hook' as usual. That's especially useful if y= our cleanup needs to interact with Emacs.=C2=A0

--001a1144472cec8551054cd36889--