chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] posix:process hangup when reading process output (wi


From: felix winkelmann
Subject: Re: [Chicken-users] posix:process hangup when reading process output (win)
Date: Thu, 2 Nov 2006 23:26:09 +0100

On 10/25/06, $) <address@hidden> wrote:
Hi!
I am working on windows system, Chicken v2, Build 41.
I try to start a process from scheme script and read what that process had
produced. My script hangs for unknown reasons. Here is a sample code:

(require-extension posix)
(define-values (p1 p2 pid) (process "ls"))
(define response (read-sring #f p1)) ; <--- hangs here
(process-wait pid)

If I try to read output line by line (i.e with (read-line p1)) everything
goes fine until the call to read-line following those call to read-line that
consumed the last line of output. It appears that input port summoned by
process function does not recognize EOF, am I right?

Sorry, this has taken way to long.

I have been able to debug this on my horrible little nasty bitch of
a Windows notebook and can currently only provide a dirty little
hack (attached): It seems the Win32's ReadFile returns
ERROR_BROKEN_PIPE after reading the last character of input (instead of
hanging) but this may also be caused because the posixwin equivalent
of "process" is implemented somewhat differently than the UNIX version
(I haven't written this code, so I'm a bit slow going through it). Additionally
the error-detection code had a small bug.
Oh, the hack: after getting EPIPE, the port is just treated as being eof'd
and closing the (input- or output-) ports will silently do nothing.


Things goes more weird when csi is running without a console window (I
believe CGI programs are started this way). In the later case process
function fails to apply IO redirection to the process started (a spawned
process owns a brand new console window and output is showing there).

Windows does very weird things regarding the handling of consoles.
I'm afraid I'm unable to help much here, but will try to dig further.


cheers,
felix


--
http://galinha.ucpel.tche.br:8081/blog/blog.ssp

Attachment: posixwin.scm.diff
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]