GNU bug report logs -
#23963
25.0.95; Feature request: setup-unwind-protect, complementing unwind-protect
Previous Next
To reply to this bug, email your comments to 23963 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23963
; Package
emacs
.
(Wed, 13 Jul 2016 06:29:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Markus Triska <triska <at> metalevel.at>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 13 Jul 2016 06:29:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23963
; Package
emacs
.
(Sat, 27 Jan 2018 21:18:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 23963 <at> debbugs.gnu.org (full text, mbox):
Markus Triska <triska <at> metalevel.at> 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
This bug report was last modified 7 years and 140 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.