* bug#8929: 24.0.50; tramp hangs when process died
@ 2011-06-24 13:21 Sébastien Gross
2011-06-26 8:48 ` Michael Albinus
0 siblings, 1 reply; 6+ messages in thread
From: Sébastien Gross @ 2011-06-24 13:21 UTC (permalink / raw
To: 8929
Hi,
Using tramp to edit remote files creates some ssh processes.
When this process dies for some reasons (such ad IP change or network
outrage), the associated buffer is still alive and makes tramp hanging
when trying to reconnect the remote host.
This behavior happens every time I carry my laptop (in suspend to disk
or suspend to ram mode) from my home to my office (or the way back).
Here is a patch (for tramp-sh.el) to add a sentinel that kills the
process buffer when the process exit:
--- tramp-sh.el.o 2011-06-24 14:44:09.023169775 +0200
+++ tramp-sh.el 2011-06-24 14:52:57.383172776 +0200
@@ -4277,6 +4277,13 @@
(tramp-get-connection-buffer vec)
tramp-encoding-shell))))
+ ;; Kill buffer when process died.
+ (set-process-sentinel
+ p
+ (lambda (proc change)
+ (when (eq (process-status proc) 'exit)
+ (kill-buffer (process-buffer proc)))
+
(tramp-message
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
Hope this doesn't break anything.
Cheers.
In GNU Emacs 24.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1)
of 2011-05-23 on builder1-tc2ams, modified by Debian
(emacs-snapshot package, version 1:20110520-1+squeeze)
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
configured using `configure '--build' 'x86_64-linux-gnu' '--host' 'x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.0.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.0.50/site-lisp:/usr/share/emacs/site-lisp' '--without-compress-info' '--with-x=yes' '--with-x-toolkit=gtk' '--with-imagemagick=yes' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed' 'CPPFLAGS=''
--
Sébastien Gross
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8929: 24.0.50; tramp hangs when process died
2011-06-24 13:21 bug#8929: 24.0.50; tramp hangs when process died Sébastien Gross
@ 2011-06-26 8:48 ` Michael Albinus
2011-06-27 8:57 ` Sébastien Gross
0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2011-06-26 8:48 UTC (permalink / raw
To: Sébastien Gross; +Cc: 8929
Sébastien Gross <seb@chezwam.org> writes:
> Hi,
Hi,
> When this process dies for some reasons (such ad IP change or network
> outrage), the associated buffer is still alive and makes tramp hanging
> when trying to reconnect the remote host.
>
> This behavior happens every time I carry my laptop (in suspend to disk
> or suspend to ram mode) from my home to my office (or the way back).
>
> Here is a patch (for tramp-sh.el) to add a sentinel that kills the
> process buffer when the process exit:
>
> Hope this doesn't break anything.
I wouldn't like to add such a radical buffer kill. Asynchronous
processes on remote hosts would loose their output buffer, when they
have finished. Debugging of Tramp problems would be harder.
On GNU Linux systems, it might be possible to catch D-Bus signals for
resuming the system after hibernate or suspend. Could you, please, eval
the following lines, and see whether Tramp behaves better?
--8<---------------cut here---------------start------------->8---
(require 'dbus)
(dbus-register-signal
:system "org.freedesktop.UPower" "/org/freedesktop/UPower"
"org.freedesktop.UPower" "Resuming" 'tramp-cleanup-all-connections)
--8<---------------cut here---------------end--------------->8---
If this works for you (it does for me), I would add a custom option for
enabling this behaviour.
Maybe we shall even introduce a variable `system-resume-hook', which
keeps functions to be called when Emacs continues to run after a
hibernate or suspend of the machine.
> Cheers.
Best regards, Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8929: 24.0.50; tramp hangs when process died
2011-06-26 8:48 ` Michael Albinus
@ 2011-06-27 8:57 ` Sébastien Gross
2011-07-01 12:59 ` Michael Albinus
0 siblings, 1 reply; 6+ messages in thread
From: Sébastien Gross @ 2011-06-27 8:57 UTC (permalink / raw
To: Michael Albinus; +Cc: Sébastien Gross, 8929
Michael Albinus <michael.albinus@gmx.de> writes:
Hi,
> I wouldn't like to add such a radical buffer kill. Asynchronous
> processes on remote hosts would loose their output buffer, when they
> have finished. Debugging of Tramp problems would be harder.
I do totally agree with you about the debugging purposes. So why not
setting up a variable such as:
(defcustom tramp-kill-process-buffer-on-exit nil
"Kill remote shell buffer process if connection with remote host is
lost."
:group 'tramp
:type 'boolean)
Setting by default this variable to `nil' doesn't affect current tramp
behavior. Then one can chose how tramp should handle process ending by
changing `tramp-kill-process-buffer-on-exit'.
And add in `tramp-maybe-open-connection':
;; Kill buffer when process died.
(when tramp-kill-process-buffer-on-exit
(set-process-sentinel
p
(lambda (proc change)
(when (eq (process-status proc) 'exit)
(kill-buffer (process-buffer proc)))
>
> On GNU Linux systems, it might be possible to catch D-Bus signals for
> resuming the system after hibernate or suspend. Could you, please, eval
> the following lines, and see whether Tramp behaves better?
>
> (require 'dbus)
> (dbus-register-signal
> :system "org.freedesktop.UPower" "/org/freedesktop/UPower"
> "org.freedesktop.UPower" "Resuming" 'tramp-cleanup-all-connections)
>
> If this works for you (it does for me), I would add a custom option for
> enabling this behaviour.
This works fine but on in one use case on power resuming. If for some
reason the connection with a remote host is lost, the dbus solution acts
more like a workaround, not like a global issue solving.
Cheers,
--
Sébastien Gross
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8929: 24.0.50; tramp hangs when process died
2011-06-27 8:57 ` Sébastien Gross
@ 2011-07-01 12:59 ` Michael Albinus
2011-07-07 13:24 ` Michael Albinus
0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2011-07-01 12:59 UTC (permalink / raw
To: Sébastien Gross; +Cc: 8929
Sébastien Gross <seb@chezwam.org> writes:
> Hi,
Hi Sébastien,
>> I wouldn't like to add such a radical buffer kill. Asynchronous
>> processes on remote hosts would loose their output buffer, when they
>> have finished. Debugging of Tramp problems would be harder.
>
> I do totally agree with you about the debugging purposes.
I've checked the code: we have already a sentinel, which adds some
cleanup in case a process died. But this is applied only for
asynchronous processes.
I've extended the sentinel a little bit, and I've moved the sentinel
setup to `tramp-maybe-open-connection'. It is activated for all
processes now.
Could you, please, check the patch, whether it is sufficient to your needs?
--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/tramp/lisp/tramp-sh.el.~1~ 2011-07-01 11:25:11.000000000 +0200
--- /home/albinus/src/tramp/lisp/tramp-sh.el 2011-07-01 14:35:41.304448000 +0200
***************
*** 2669,2674 ****
--- 2669,2675 ----
(let ((vec (tramp-get-connection-property proc "vector" nil)))
(when vec
(tramp-message vec 5 "Sentinel called: `%s' `%s'" proc event)
+ (tramp-flush-connection-property proc)
(tramp-flush-directory-property vec "")))))
;; We use BUFFER also as connection buffer during setup. Because of
***************
*** 2721,2729 ****
v 'file-error
"pty association is not supported for `%s'" name)))))
(let ((p (tramp-get-connection-process v)))
! ;; Set sentinel and query flag for this process.
! (tramp-set-connection-property p "vector" v)
! (set-process-sentinel p 'tramp-process-sentinel)
(tramp-compat-set-process-query-on-exit-flag p t)
;; Return process.
p)))
--- 2722,2728 ----
v 'file-error
"pty association is not supported for `%s'" name)))))
(let ((p (tramp-get-connection-process v)))
! ;; Set query flag for this process.
(tramp-compat-set-process-query-on-exit-flag p t)
;; Return process.
p)))
***************
*** 4300,4310 ****
tramp-encoding-command-interactive)
(list tramp-encoding-shell))))))
(tramp-message
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
;; Check whether process is alive.
- (tramp-compat-set-process-query-on-exit-flag p nil)
(tramp-barf-if-no-shell-prompt
p 60 "Couldn't find local shell prompt %s" tramp-encoding-shell)
--- 4299,4313 ----
tramp-encoding-command-interactive)
(list tramp-encoding-shell))))))
+ ;; Set sentinel and query flag.
+ (tramp-set-connection-property p "vector" vec)
+ (set-process-sentinel p 'tramp-process-sentinel)
+ (tramp-compat-set-process-query-on-exit-flag p nil)
+
(tramp-message
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
;; Check whether process is alive.
(tramp-barf-if-no-shell-prompt
p 60 "Couldn't find local shell prompt %s" tramp-encoding-shell)
--8<---------------cut here---------------end--------------->8---
> Cheers,
Best regards, Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8929: 24.0.50; tramp hangs when process died
2011-07-01 12:59 ` Michael Albinus
@ 2011-07-07 13:24 ` Michael Albinus
[not found] ` <87wrfu9kkd.fsf@ubik.of1par.int.rtblw.com>
0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2011-07-07 13:24 UTC (permalink / raw
To: Sébastien Gross; +Cc: 8929
Michael Albinus <michael.albinus@gmx.de> writes:
Hi Sébastien,
> I've extended the sentinel a little bit, and I've moved the sentinel
> setup to `tramp-maybe-open-connection'. It is activated for all
> processes now.
>
> Could you, please, check the patch, whether it is sufficient to your needs?
Does the patch work for you? I have submitted it to the trunk, meanwhile.
If yes, we could close the bug.
>> Cheers,
Best regards, Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8929: 24.0.50; tramp hangs when process died
[not found] ` <87wrfu9kkd.fsf@ubik.of1par.int.rtblw.com>
@ 2011-07-07 15:52 ` Michael Albinus
0 siblings, 0 replies; 6+ messages in thread
From: Michael Albinus @ 2011-07-07 15:52 UTC (permalink / raw
To: Sébastien Gross; +Cc: 8929-done
Sébastien Gross <seb@chezwam.org> writes:
> Hi Michael,
Hi Sébastien,
> Seems to be OK but I haven't tested it in all cases.
> I'll come back to you if I find something wrong in the future.
Thanks for testing. I'll close the bug; feel free to come back if there
are still problems.
> Thanks for your support.
>
> Cheers
Best regards, Michael.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-07-07 15:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-24 13:21 bug#8929: 24.0.50; tramp hangs when process died Sébastien Gross
2011-06-26 8:48 ` Michael Albinus
2011-06-27 8:57 ` Sébastien Gross
2011-07-01 12:59 ` Michael Albinus
2011-07-07 13:24 ` Michael Albinus
[not found] ` <87wrfu9kkd.fsf@ubik.of1par.int.rtblw.com>
2011-07-07 15:52 ` Michael Albinus
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.