From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: call-process blocks the active thread Date: Thu, 07 Sep 2017 20:56:37 -0700 Message-ID: <87y3ppyhai.fsf@ericabrahamsen.net> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1504843202 13214 195.159.176.226 (8 Sep 2017 04:00:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 8 Sep 2017 04:00:02 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 08 05:59:46 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqAS0-0001m0-AA for ged-emacs-devel@m.gmane.org; Fri, 08 Sep 2017 05:59:28 +0200 Original-Received: from localhost ([::1]:43191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqAS7-0001iQ-Gu for ged-emacs-devel@m.gmane.org; Thu, 07 Sep 2017 23:59:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqARD-0001eb-At for emacs-devel@gnu.org; Thu, 07 Sep 2017 23:58:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqAR8-0005VW-N4 for emacs-devel@gnu.org; Thu, 07 Sep 2017 23:58:39 -0400 Original-Received: from [195.159.176.226] (port=39483 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dqAR8-0005T3-FJ for emacs-devel@gnu.org; Thu, 07 Sep 2017 23:58:34 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dqAQi-0006di-RO for emacs-devel@gnu.org; Fri, 08 Sep 2017 05:58:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 22 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:cO8nz9M74/R83Md9LJmIUiAGK/k= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218001 Archived-At: Elias Mårtenson 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 ))) (while (process-live-p proc) (accept-process-output proc))) caveat: I am not a thread expert Eric