jed-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: asynchronous process problem


On Tue, Mar 23, 2004 at 05:57:15PM -0500, John E. Davis wrote:
> Guenter Milde <g.milde@xxxxxx> wrote:
> >ashell();
> >send_process (AShell_Id, "ispell -a \n");
> >send_process (AShell_Id, "uffe");
 
> My feeling is that the problem may be due to a race condition that is
> causing the problem.  For example, I also see the same problem when
> pasting 
> 
>    bash
>    ispell -a
>    uffe
> 
> into an xterm window.  

You are right, this gives exactly the same result.

> Based upon this test I recommend that you call
> sleep between ashell and send_process, i.e.,
> 
>    ashell();
>    sleep (1);
>    send_process (AShell_Id, "ispell -a \n");
>    send_process (AShell_Id, "uffe\n");
> 
> This gives the underlying shell some time to get set up and initialize
> the pseudo-terminal.

I wonder (and did a lot of testing to find out), whether there is a way
to determine, when the process has initialized.

Let jed sleep while the user wants a word checked doesnot seem very
friendly to me. Also, finding the right time to sleep is tricky (if not
impossible)

I tried to replace sleep(1) with get_process_input(10) but this did not
always solve the problem. Sometimes an update_sans_update_hook(0) helped,
but also not always...

Ispell (asynchron) did contain a more elaborated version of the following

static variable ID

% open an ispell process and set up communication
% (do nothing, if ispell is already running)
static define start_ispell_process ()
{
   % start ispell (if not already running)
   if (ID < 0)
     {
	variable args = strtok ("ispell -a");
	foreach (args)
	  ; % push on stack
	ID = open_process (length(args) - 1);
	get_process_input(10);
	% terse mode
	send_process(ID, "!\n");
	% the first call to the newly created process (sometimes) fails,
	% if we do not update here!
	% update_sans_update_hook(0);

	set_process (ID, "signal", &signal_handler);
	set_process (ID, "output", &output_handler);
	process_query_at_exit (ID, 0);
     }
}


public define ispell()
{
   start_ispell_process (); % start ispell if not already running

   !if (is_visible_mark)
     mark_word(ispell_wordchars);
   send_process(ID, bufsubstr());
}

(My new ispell version circumvents the problem by not using asynchroneous
ispelling any more (as generally we want to see the result of an ispell
request before proceeding to something else).


Günter


-- 
G.Milde at web.de

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]