Hi Michiel,

It appears to be an issue with fork under cygwin. I've duplicated your same
problem. I've ran into similar issues with fork under windows/cygwin and
found it to be unstable.  You can google to find other instances:
http://cygwin.com/ml/cygwin/2012-06/msg00331.html, I came across this
several months ago as well to see if there's a way to eliminate the fork:
but found it to be a dead end. In the end, I've used cygwin for light, non
web work and then used a virtual image otherwise. I've also tinkered with
ersatz and web -  http://picolisp.com/5000/!wiki?ErsatzWebApp for the same

Specifically windows error 6 seems to be an issue with an invalid handle. I
suspect fork() is having an issue sharing the handle in the new process.

I suggest avoiding fork() altogether. As a proof of concept, you can
redefine server() to not use fork. This may introduce other errors. I've
only done limited testing with it.

This example works for me and prints out the # of hits that have been
stored in the db.


(load "@lib/http.l" )

(de server (P H)
      *Port P
      *Port1 P
      *Home (cons H (chop H))
      P (port *Port) )
      (setq *Sock (listen P))
      (http *Sock)
      (close *Sock) ) )

(de mytest ()
   (prinl "hello")
   (put! (get *DB) 'hits (inc (get *DB 'hits)))
   (prinl (get *DB 'hits))
   (prinl (val *DB)) )

(de go ()
   (pool "testdb1" )
   (or (get *DB 'hits) (put! (get *DB) 'hits 0))
   (prinl (val *DB) ) #does not give an error
   (server 8080 "!mytest") )

Hope that helps in some way.


On Fri, Aug 10, 2012 at 11:58 PM, Michiel van Oosten <michieljo...@gmail.com
> wrote:

> Hi,
> I ran into the same problem as Yechiel described in an earlier email to this 
> mailing list (quoted at the bottom).
> I did as Alexander suggested in his email to Yechiel,  and got the following 
> results:
> -------------------
> Running in cygwin on Windows7 64 bit with the following in testwindows.l
> (load "@lib/http.l" )
> (de mytest ()
>   (prinl "hello")
>   (val *DB) #gives the error
>  )
> (de go ()
>    (pool "testdb1" )
>    (val *DB) #does not give an error
>    (server 8080 "!mytest") )
> results go to standard out, written to the file straceout:
> $ pil testwindows.l -go &
> [1] 6868
> $ strace -p 6868 1>straceout
> DB read: Bad file descriptor
> ? *DB
> -> {1}
> ? (val *DB)
> DB read: Bad file descriptor
> [Control-c]

> Hi Michiel,
> thanks for the strace info.
> However, the output from cygwin's strace looks completely different from
> the one under Linux, and unfortunately it doesn't include any
> information which helps to locate the program's execution, like strings
> read or printed (only addresses like in "write(2, 0x200106CC, 29))".
> This makes it almost impossible to follow what the program is actually
> doing.
> > Seems to run into windows error 6 a number of times. Doesn't mean
> Yes, but I'm not sure if this is really an error condition. It seems to
> happen always after some obscure 'seterrno_from_nt_status' call, so
> perhaps it is just some normal administrative processing?
> > anything to me, but maybe to you or somebody else?
> Sorry, no. And I also cannot try as I have nether Windows nor Cygwin.
> Cheers,
> - Alex
> -----------------------------------------------
> Hopefully somebody has some ideas or solutions, it would be nice to be able 
> to use a fully working picolisp with a minimal cygwin as a kind of portable, 
> easily deployable full database/web server//gui bundle on windows.
> Regards,
> Michiel
> ---------------------------------------------------
> Quoted from earlier email to mailinglist:
> Hi Yechiel,
> > but I got this error:
> >
> > "DB read: Bad file descriptor" and localhost 8080 is waiting

Reply via email to