From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= Newsgroups: gmane.emacs.help Subject: Re: waiting for asynchronous processes Date: Sun, 16 Oct 2011 00:24:52 +0200 Message-ID: <87hb39zydn.fsf@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1318717841 18084 80.91.229.12 (15 Oct 2011 22:30:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 15 Oct 2011 22:30:41 +0000 (UTC) Cc: help-gnu-emacs List To: Perry Smith Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 16 00:30:37 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RFCkW-0004fR-WF for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Oct 2011 00:30:37 +0200 Original-Received: from localhost ([::1]:39154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFCkV-00005y-OR for geh-help-gnu-emacs@m.gmane.org; Sat, 15 Oct 2011 18:30:35 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:43834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFCkR-00005p-Ml for help-gnu-emacs@gnu.org; Sat, 15 Oct 2011 18:30:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFCkQ-0000Os-Gs for help-gnu-emacs@gnu.org; Sat, 15 Oct 2011 18:30:31 -0400 Original-Received: from mail-bw0-f41.google.com ([209.85.214.41]:47859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFCkQ-0000Oo-85 for help-gnu-emacs@gnu.org; Sat, 15 Oct 2011 18:30:30 -0400 Original-Received: by bkbzu5 with SMTP id zu5so4391686bkb.0 for ; Sat, 15 Oct 2011 15:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:content-transfer-encoding; bh=DPHzdOIlesbJNvQlFoz4r24Gq+hdeiaUOq3I+64uJ98=; b=jS1cT/OopM6LP/zxIXyX9EcyWDzYMpAM+xbc9Ns7j8vxqGDs28CLs8qg7IvNR+vT7b agxJSAYLAG626mBy+STrJqhYoVmdcS5+uf7XfUEIswXil8MW2rySHZw3zjfKONzIusV0 QRpoGILI6+195cTehE+NTDKpSckv0T9NeqFEs= Original-Received: by 10.223.77.26 with SMTP id e26mr4029506fak.37.1318717828691; Sat, 15 Oct 2011 15:30:28 -0700 (PDT) Original-Received: from localhost (176.119.broadband10.iol.cz. [90.177.119.176]) by mx.google.com with ESMTPS id r6sm13055204fam.0.2011.10.15.15.30.27 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 15 Oct 2011 15:30:27 -0700 (PDT) In-Reply-To: (Perry Smith's message of "Sat, 15 Oct 2011 12:20:44 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.214.41 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:82567 Archived-At: On Sat, 15 Oct 2011 19:20:44 +0200 Perry Smith wrote: > I started looking for a built in way to wait for an asynchronous command = to > complete and discovered that I had written one long long time ago in a ga= laxy > far far away. > >> (defun wait-for-async-process ( proc ) >> "Wait for PROC to finish" >> (while (null (eq (process-status proc) 'exit)) >> (accept-process-output))) Looks like a terrible hack to me. > I went ahead and looked for something like it in the distribution but did= n't see it. > > I'm curious if I overlooked it. I doubt it. If you want to wait for the process in the way you seem to want to wait for it, why don't you just use a synchronous process to begin with? If you _do_ want the non-waiting advantage of asynchronous processes, the usual way to handle state changes (s.a. when the process finishes) is to use sentinels, see e.g. (info "(elisp)Sentinels"). --=20 =C5=A0t=C4=9Bp=C3=A1n