all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-devel@gnu.org
Subject: Re: call-process blocks the active thread
Date: Thu, 07 Sep 2017 20:56:37 -0700	[thread overview]
Message-ID: <87y3ppyhai.fsf@ericabrahamsen.net> (raw)
In-Reply-To: CADtN0WL1G-aUw_BdnLL_5OQ4S9psUZjGs4yee50+3fPLM6BpFg@mail.gmail.com

Elias Mårtenson <lokedhs@gmail.com> writes:

> I was trying to use ‘call-process’ in a thread in order to not have to deal with process buffers and the like while still being able to run an external program in the
> background.
>
> As it turns out, ‘call-process’ hangs all of Emacs while the external program is run.
>
> To reproduce, simply type M-: (make-thread (lambda () (call-process "sleep" nil nil nil "2")))
>
> This will hang Emacs for 2 seconds.

`call-process' will block Emacs no matter what. Threads are good for
encapsulating environment, but they don't really change the nature of
synchronous/asynchronous external processes. You still have to do:

(let ((proc (start-process <etc>)))
  (while (process-live-p proc)
    (accept-process-output proc)))
    
caveat: I am not a thread expert

Eric




  reply	other threads:[~2017-09-08  3:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-08  3:00 call-process blocks the active thread Elias Mårtenson
2017-09-08  3:56 ` Eric Abrahamsen [this message]
2017-09-08  7:01 ` Eli Zaretskii
2017-09-08  7:45   ` Stefan Monnier
2017-09-08  8:06     ` Eli Zaretskii
2017-09-08 10:36   ` Elias Mårtenson
2017-09-08 11:27     ` Philipp Stephani
2017-09-08 12:16     ` Eli Zaretskii
2017-09-08 16:12       ` Tom Tromey
2017-09-08 18:43         ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y3ppyhai.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.