newLISP Fan Club

Forum => newLISP and the O.S. => Topic started by: Robert Gorenc on December 02, 2009, 07:40:48 AM

Title: winfork and process problem on windows
Post by: Robert Gorenc on December 02, 2009, 07:40:48 AM
Hi,

I was searching for forking possibility on windows and found winfork, but it seems that is not working:

the response from newlisp is:

>(winfork '(+ 1 2))

1832

>

ERR: missing parenthesis : "...(silent  



After looking in source and little debuging, also found that simple process invocation

> (process  {newlisp -e "(+ 1 2)"})

1868

>

ERR: string token too long : "(+"



also generate error????

Is this bug or feature? :-) or I'm doing something wrong. I'm using newlisp v.10.1.5 and v.10.1.6 and on both version is same.

So I think there is no problem in winfork....

On Linux everything is working fine, process invocation is working, but there I prefer spawn....



bye,

Robert
Title: Re: winfork and process problem on windows
Post by: cormullion on December 02, 2009, 09:33:02 AM
Not able to try this here, but if the code predates newLISP version 10 then there have been some changes in the syntax of a few functions - write-buffer perhaps? Could be worth checking.
Title: Re: winfork and process problem on windows
Post by: m35 on December 02, 2009, 11:01:26 AM
Unfortunately I don't think the winfork.lsp module has been updated in any way in a long time. I also don't believe it's hosted on, or even linked anywhere on the official newLISP site, so we can't really remove it. It might be wise for whoever is hosting it to remove it, update it, or put a big disclaimer that it definitely won't work in recent versions.



How did you come across the winfork.lsp module, and what are you trying to use it for?
Title: Re: winfork and process problem on windows
Post by: Robert Gorenc on December 02, 2009, 01:11:46 PM
Well, someone, perhaps Peter, mentioned in older posts, so I wanted to try it because under windows spawn is not working. It can be downloaded from his site.

I don't think that this is not working because of some different behaving function, I can't properly start another newlisp -e via process.....

But biger problem for me is that (process {newlisp -e "(+1 2)"}) is not working, it gives error message mentioned on my previous post.

Simply I tried to use idea from Peter's winfork, to start other newlisp process, copy environment, but is not working this way.

I tried other combination, to start via process newlisp -c waiting on some port, then send source code and execute required function and this works fine, but is not easy to use it like fork or spawn.

I need it because I want to run several things in parallel, to get some http pages from slow data generating web server and i'm stuck on this poor windows xp os...
Title: Re: winfork and process problem on windows
Post by: Lutz on December 02, 2009, 02:29:43 PM
On Windows add another pair of single quotes:


(process {newlisp -e '"(+ 3 4)"'})


For a 'fork' in Windows, define this:


(define-macro (fork expr)
(save "all")
(append-file "all" (string "rn" expr "rn(exit)rn"))
(process "newlisp all"))


Pass the expression to be evaluated unquoted:


(fork (write-file "page.html" (get-url "http://newlisp.org")))

The 'fork' will return at once and the page is retrieved and written in the background.



If you have several 'fork' calls one after the other, they might interfere with each other using the same file-name "all" you could use (uuid) to create a unique file-name and then delete it at the end of the 'fork' function.
Title: Re: winfork and process problem on windows
Post by: Robert Gorenc on December 03, 2009, 02:07:49 AM
thanks Lutz,

that is what I need!