[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: waiting for asynchronous processes
From: |
Perry Smith |
Subject: |
Re: waiting for asynchronous processes |
Date: |
Sat, 15 Oct 2011 19:17:03 -0500 |
On Oct 15, 2011, at 5:24 PM, Štěpán Němec wrote:
> 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 galaxy
>> 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 didn'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").
Well, as I said, what I really wanted to use is "grep" (the built in emacs
function).
I assumed I couldn't reach in and change him from asynchronous to synchronous
-- can I?
pedz