From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniele Pizzolli Subject: [BUG] babel hangs executing some shell commands in session Date: Sun, 22 Feb 2015 09:57:22 +0100 Message-ID: <86sidyiarx.fsf@me.localhost.invalid> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPSM1-0008E3-AC for emacs-orgmode@gnu.org; Sun, 22 Feb 2015 03:57:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPSLx-0003Qt-Rz for emacs-orgmode@gnu.org; Sun, 22 Feb 2015 03:57:33 -0500 Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]:59930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPSLx-0003QQ-It for emacs-orgmode@gnu.org; Sun, 22 Feb 2015 03:57:29 -0500 Received: from mfilter25-d.gandi.net (mfilter25-d.gandi.net [217.70.178.153]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 933D141C054 for ; Sun, 22 Feb 2015 09:57:24 +0100 (CET) Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter25-d.gandi.net (mfilter25-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id QmzF+Ajpvhh8 for ; Sun, 22 Feb 2015 09:57:23 +0100 (CET) Received: from localhost.invalid (host53-18-static.13-188-b.business.telecomitalia.it [188.13.18.53]) (Authenticated sender: me@toel.it) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id E34A641C06A for ; Sun, 22 Feb 2015 09:57:22 +0100 (CET) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hello, I am going to give an interactive presentation of git using org-mode and babel. But I am stuck with random hangs when executing the code with =C-c C-c= and during export. I am using Org-mode version 8.2.4 (8.2.4-dist @ /home/vagrant/.emacs.d/el-get/org-mode/lisp/) The hangs does not always happen, but if you execute the following code blocks a couple of times you should ran into the problem. Assumption: the file =/etc/sudoers= contains something like "vagrant ALL=(ALL) NOPASSWD:ALL" to not ask password with an interactive prompt. #+PROPERTY: header-args:shell :session *git-shell* :dir /vagrant #+PROPERTY: header-args:shell+ :exports both :results output verbatim replace #+PROPERTY: header-args:shell+ :tangle git_demo.sh :shebang "#!/bin/bash" :comments org #+BEGIN_SRC shell sudo apt-get remove --purge --yes git && sudo apt-get autoremove --yes #+END_SRC #+BEGIN_SRC shell sudo apt-get install --yes git #+END_SRC My guess, by looking at the *git-shell* buffer after waiting a minute and hitting C-g, is that the output of echo 'org_babel_sh_eoe' sometimes is eaten by some ansi sequence of the interactive command. See for example the following cut and paste from the *git-shell* buffer. Do babel do something nasty with the shell/term emulator? #+begin_example vagrant@git-pratical:/vagrant$ sudo apt-get remove --purge --yes git && sudo apt-get autoremove --yes Reading package lists... 0%echo 'org_babel_sh_eoe' Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: git-man liberror-perl Use 'apt-get autoremove' to remove them. The following packages will be REMOVED: git* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 22.2 MB disk space will be freed. (Reading database ... 122644 files and directories currently installed.) Removing git (1:2.3.0-0ppa1~ubuntu12.04.1) ... Purging configuration files for git (1:2.3.0-0ppa1~ubuntu12.04.1) ... Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: git-man liberror-perl 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. After this operation, 1,477 kB disk space will be freed. (Reading database ... 122040 files and directories currently installed.) Removing git-man (1:2.3.0-0ppa1~ubuntu12.04.1) ... Removing liberror-perl (0.17-1.1) ... Processing triggers for man-db (2.6.7.1-1ubuntu1) ... vagrant@git-pratical:/vagrant$ #+end_example An indirect confirmation of my guess comes from a test: redirecting the output of the command and then printing it. Using this workaround babel never hangs: #+BEGIN_SRC shell (any_strange_command) 1>/tmp/1 2>/tmp/2; cat /tmp/1 /tmp/2 #+END_SRC Do you think that is easy to fix babel or can you suggest a less invasive and more comprehensive workaround? Wrapping loops and pipes is going to clutter the code to the point that is better to use a script with inline comments rather that using the org-mode buffer. Thanks in advance, Daniele