emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: call-process blocks the active thread


From: Eric Abrahamsen
Subject: Re: call-process blocks the active thread
Date: Thu, 07 Sep 2017 20:56:37 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Elias Mårtenson <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]