Received: (at 23963) by debbugs.gnu.org; 27 Jan 2018 21:17:26 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 27 16:17:26 2018 Received: from localhost ([127.0.0.1]:45541 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1efXqn-0000P7-Of for submit <at> debbugs.gnu.org; Sat, 27 Jan 2018 16:17:25 -0500 Received: from chene.dit.umontreal.ca ([132.204.246.20]:52753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1efXqk-0000Oy-O4 for 23963 <at> debbugs.gnu.org; Sat, 27 Jan 2018 16:17:24 -0500 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w0RLHJdo012392; Sat, 27 Jan 2018 16:17:20 -0500 Received: by ceviche.home (Postfix, from userid 20848) id 95A296629F; Sat, 27 Jan 2018 16:17:19 -0500 (EST) From: Stefan Monnier <monnier@HIDDEN> To: Markus Triska <triska@HIDDEN> Subject: Re: bug#23963: 25.0.95; Feature request: setup-unwind-protect, complementing unwind-protect Message-ID: <jwvlggjnh6u.fsf-monnier+bug#23963@HIDDEN> References: <m2d1mif3vm.fsf@HIDDEN> Date: Sat, 27 Jan 2018 16:17:19 -0500 In-Reply-To: <m2d1mif3vm.fsf@HIDDEN> (Markus Triska's message of "Wed, 13 Jul 2016 08:28:45 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6209=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6209> : inlines <6344> : streams <1777278> : uri <2580824> X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 23963 Cc: 23963 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.3 (-) Markus Triska <triska@HIDDEN> writes: > With this primitive, we could write the example above as: > > (setup-unwind-protect > (setq process (ftp-...)) > (progn > ;; use process ... > (delete-process process)) Given my dislike of `setq` I'd rather use something else. This said, we also have another problem: if the user hits C-g twice in a row, the second may interrupt the `delete-process` itself. So I think what we "really" want is more like (let ((oi inhibit-quit) (inhibit-quit t)) (let ((process (ftp-...))) (unwind-protect (let ((inhibit-quit oi)) ..use process..) (delete-process process)))) At the same time, any function whose name starts with "ftp-" is likely a bad candidate for running it in a context where it can't be interrupted (it's likely that in various circumstances it could hang, in which case the user should be able to hit C-g). Stefan
bug-gnu-emacs@HIDDEN
:bug#23963
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 13 Jul 2016 06:28:59 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 13 02:28:59 2016 Received: from localhost ([127.0.0.1]:48971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1bNDfG-0006fM-Ps for submit <at> debbugs.gnu.org; Wed, 13 Jul 2016 02:28:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35371) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <triska@HIDDEN>) id 1bNDfF-0006f9-2Q for submit <at> debbugs.gnu.org; Wed, 13 Jul 2016 02:28:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <triska@HIDDEN>) id 1bNDf8-00089r-S7 for submit <at> debbugs.gnu.org; Wed, 13 Jul 2016 02:28:51 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:44280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <triska@HIDDEN>) id 1bNDf8-00089g-P1 for submit <at> debbugs.gnu.org; Wed, 13 Jul 2016 02:28:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <triska@HIDDEN>) id 1bNDf6-0001uK-FM for bug-gnu-emacs@HIDDEN; Wed, 13 Jul 2016 02:28:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <triska@HIDDEN>) id 1bNDf2-00089H-84 for bug-gnu-emacs@HIDDEN; Wed, 13 Jul 2016 02:28:47 -0400 Received: from metalevel.at ([78.46.218.83]:41316) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <triska@HIDDEN>) id 1bNDf2-00089A-14 for bug-gnu-emacs@HIDDEN; Wed, 13 Jul 2016 02:28:44 -0400 Received: from dawn.meta (localhost.localdomain [127.0.0.1]) by metalevel.at (Postfix) with ESMTP id 8FD91A05DE for <bug-gnu-emacs@HIDDEN>; Wed, 13 Jul 2016 08:28:42 +0200 (CEST) Received: by dawn.meta (Postfix, from userid 501) id 092571AA32D0; Wed, 13 Jul 2016 08:28:45 +0200 (CEST) From: Markus Triska <triska@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: 25.0.95; Feature request: setup-unwind-protect, complementing unwind-protect Date: Wed, 13 Jul 2016 08:28:45 +0200 Message-ID: <m2d1mif3vm.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -5.0 (-----) The manual entry of `unwind-protect' shows an example whose essence is: (unwind-protect (progn (setq process (ftp-...)) ;; use process (delete-process process)) It adds the following important explanation: This example has a small [sic] bug: if the user types `C-g' to quit, and the quit happens immediately after the function `ftp-...' returns but before the variable `process' is set, *the process will not be killed*. There is no easy way to fix this bug, but at least it is very unlikely. Would it be good to make such resource leak *impossible* instead? This seems quite desirable and could be done with a complementing primitive. Please consider a new primitive `setup-unwind-protect' with 3 arguments: 1. SETUPFORM, called in such a way that it *cannot be interrupted* 2. BODYFORM, like in unwind-protect, called after SETUPFORM 3. UNWINDFORMS, like in unwind-protect With this primitive, we could write the example above as: (setup-unwind-protect (setq process (ftp-...)) (progn ;; use process ... (delete-process process)) Please consider adding such a construct to Emacs. A precedence for such a construct is setup_call_cleanup/3 which appears in the Prolog ISO draft standard and is already included in many systems: https://www.complang.tuwien.ac.at/ulrich/iso-prolog/N215 Thank you and all the best! Markus In GNU Emacs 25.0.95.4 (x86_64-apple-darwin15.5.0, X toolkit, Xaw scroll bars) of 2016-07-05 built on mt-imac Repository revision: e3b039d1a0e611d6619ed3ce67d125160d644ebc Windowing system distributor 'The X.Org Foundation', version 11.0.11502000 Configured using: 'configure --without-ns CFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK GSETTINGS NOTIFY ACL GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix
Markus Triska <triska@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#23963
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.