Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!YALE.ARPA!ram-ashwin From: ram-ashwin@YALE.ARPA (Ashwin Ram) Newsgroups: comp.emacs Subject: ACCEPT-PROCESS-OUTPUT problem Message-ID: <8711241653.AA00499@ATHENA.CS.YALE.EDU> Date: Tue, 24-Nov-87 11:53:39 EST Article-I.D.: ATHENA.8711241653.AA00499 Posted: Tue Nov 24 11:53:39 1987 Date-Received: Fri, 27-Nov-87 23:06:18 EST Sender: daemon@eddie.MIT.EDU Lines: 53 I'm trying to use start-process, process filters and accept-process-output in the following way: 1. Start-process some process foo. 2. Set its process-filter to foo-filter. One of the things the filter does is to check if a termination condition has been reached (say, foo has produced some predetermined output, or a predetermined amount of output, etc. E.g., in ispell, check to see if there is output corresponding to the last word in the buffer being checked. In gnews, check to see if a "." has been receieved all by itself on a line.) If the termination condition is reached, setq foo-done to t. ... (if ... (setq foo-done t)) ... 3. Now I do the following (I want to wait until foo has produced all its output before going on): (while (not foo-done) (accept-process-output foo)) Here's the problem I run into: Suppose foo-done is nil to start with. It does a accept-process-output. Suppose foo produces the desired final output. The accept-process-output returns, and so we go around the while. But foo-filter is still processing the last piece of output, and foo-done hasn't been setq'd to t by the time the while checks (not foo-done), so it goes around into the accept-process-output again. Now it hangs forever since foo has already produced its last piece of output. By this time foo-done is t, but it's too late. This bug is hard to reproduce since it depends on timing. It depends on how fast you go around the while vs. how fast the filter executes (often, it depends on the length of the output that the filter is processing, since that determines how soon it can setq foo-done to t. Does anyone know what I'm talking about, and what the best way to get around this is? I tried putting a (sit-for 0) after the accept-process-output; this usually works (but is a little annoying). I can put a (sit-for 2) or something, but this is even more annoying. Perhaps a function that won't return until the accept-process-output is done *and* the filter has processed the output? Thanks in advance. In case it's relevant, I'm running GNU Emacs 18.48 on an Apollo DN3000 running DOMAIN/IX (Aegis SR9.5 + Unix BSD 4.2). -- Ashwin Ram -- ARPA: Ram-Ashwin@cs.yale.edu UUCP: {decvax,linus,seismo}!yale!Ram-Ashwin BITNET: Ram@yalecs