- Subject: [jed-users] Re: A couple of questions about the new_process() function
- From: Morten Bo Johansen <mbj@xxxxxxxxx>
- Date: Tue, 17 Dec 2024 00:37:43 +0100
John E. Davis <jed@xxxxxxxxxxx> wrote:
> Morten Bo Johansen <mbj@xxxxxxxxx> wrote:
> > I get the fp1 object field but not e.g. the exit_status field.
>
> Yes, you have assigned obj to the structure returned by new_process,
> but you have left the one returned by waitpid on the stack.
Ahh, one should always check the stack! Now I finally got the
kick to put the "%S" format specifier in the status line, which
shows the stack depth (it might have alerted me).
> > Second question: Can new_process() act as a replacement for the
> > open_process() function?
>
> It depends. The new_process function knows nothing about jed's
> buffers. So if you want the output from a command invoked by the
> new_process function to get written to a buffer, you would have to
> write that code yourself.
Okay. Also from the rest you write, I guess it is not really
worth the hassle. The aspell command I showed needs to be tied
to a tty in order to be persistent and the buffer feature of
the open_process() function takes on that role - if I have
understood this correctly?
> > I may tie this process to a buffer and then send a word to it
> > and capture aspell's response as to whether the word was
> > misspelled or not.
> >
> > Can I do something similar with new_process()?
>
> I believe so. You would want to using something like:
>
> argv = ["aspell", "-d", "en", "-a"];
> variable pobj = new_process (argv; write=1, read=0);
>
> % Interact with it by writing to pobj.fp0 and reading from pobj.fp1
>
> % When finished, close the pipe and collect its return status:
> () = fclose (pobj.fp0);
> w = pobj.wait();
But this would open and close the aspell process every time I
flyspelled a word. That is MUCH slower than the approach of
keeping the process open persistently as I do with the
open_process() function. On a halfway modern computer, I
suppose it would not matter as aspell is quite fast, but there
is always soemthing to be said for speed and efficiency.
Thanks for your answer and Merry Xmas and Happy New Year!
Morten
_______________________________________________
For list information, visit <http://jedsoft.org/jed/mailinglists.html>.
[2024 date index]
[2024 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]