caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] input_line is blocking
@ 2002-05-03 12:18 Warp
  2002-05-03 14:13 ` Oliver Bandel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Warp @ 2002-05-03 12:18 UTC (permalink / raw)
  To: OCaml

Hi
I'm running "ocamlc" by using Unix.open_process_full in order to write an
automatic compiler.
Right now, it's working fine, but I got now a problem with input_line :

after running open_process_full , i'm first reading all its stdout lines of
the process until End_of_file is raised, then all its stderr lines using the
same function.

It has work fine for few weeks now, but now I found that in some cases
input_line will block, not raising End_of_file.
Actually I got the following errors (on purpose ! ) in one of my test files
:

File "player.ml", line 16, characters 6-66:
Warning: this expression should have type unit.
The implementation player.ml does not match the interface player.cmi :
Modules do not match:
  sig
     type 'a t = 'a array
     ...
     ....
  end
is not included in
   sig
     ...........
   end
The field 'c_value' is required but not provided

I tried to correct few errors, and if I correct enough of them, it works
 the call to input_line on the stdout where NO DATA is written is raising
End_of_file ) , but if correct some other errors, I won't work again...

Perhaps something to do with bufferization ?
If ocamlc generates too much data on stderr, then he waits for the calling
process to read that data, but the process is currently reading on its
stdout.... And vice-versa for ocamldep ( which generates a lot of data on
its stdout )

Any help would be apprecied

Nicolas Cannasse

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] input_line is blocking
  2002-05-03 12:18 [Caml-list] input_line is blocking Warp
@ 2002-05-03 14:13 ` Oliver Bandel
  2002-05-03 17:26 ` Remi VANICAT
  2002-05-05 13:09 ` Gerd Stolpmann
  2 siblings, 0 replies; 4+ messages in thread
From: Oliver Bandel @ 2002-05-03 14:13 UTC (permalink / raw)
  To: Warp; +Cc: OCaml



On Fri, 3 May 2002, Warp wrote:

> Hi
> I'm running "ocamlc" by using Unix.open_process_full in order to write an
> automatic compiler.
> Right now, it's working fine, but I got now a problem with input_line :
> 
> after running open_process_full , i'm first reading all its stdout lines of
> the process until End_of_file is raised, then all its stderr lines using the
> same function.
> 
> It has work fine for few weeks now, but now I found that in some cases
> input_line will block, not raising End_of_file.

In networking-applications, or when using pipes you
can't use C's standard-lib and have to use the
Unix-API directly (open/read/write/close).

Ocaml's libraries seem to be wrapping C's standard-lib
for it's normal I/O and the Unix-API for it's Unix-module.

So, if you want to use pipes/sockets, you have to use the
Unix-module's I/O-functions!

But I think in Ocaml it is not a problem to write wrapper-code.
In C this would be much effort, but I think in Ocaml it's
easy to write a network-lib....

Ciao,
   Oliver

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] input_line is blocking
  2002-05-03 12:18 [Caml-list] input_line is blocking Warp
  2002-05-03 14:13 ` Oliver Bandel
@ 2002-05-03 17:26 ` Remi VANICAT
  2002-05-05 13:09 ` Gerd Stolpmann
  2 siblings, 0 replies; 4+ messages in thread
From: Remi VANICAT @ 2002-05-03 17:26 UTC (permalink / raw)
  To: caml-list

"Warp" <warplayer@free.fr> writes:

> Hi

> Perhaps something to do with bufferization ?
> If ocamlc generates too much data on stderr, then he waits for the calling
> process to read that data, but the process is currently reading on its
> stdout.... And vice-versa for ocamldep ( which generates a lot of data on
> its stdout )

yes, I believe this is the problem.

the only solution maybe to use select

-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] input_line is blocking
  2002-05-03 12:18 [Caml-list] input_line is blocking Warp
  2002-05-03 14:13 ` Oliver Bandel
  2002-05-03 17:26 ` Remi VANICAT
@ 2002-05-05 13:09 ` Gerd Stolpmann
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Stolpmann @ 2002-05-05 13:09 UTC (permalink / raw)
  To: Warp; +Cc: OCaml


On 2002.05.03 14:18 Warp wrote:
> Hi
> I'm running "ocamlc" by using Unix.open_process_full in order to write an
> automatic compiler.
> Right now, it's working fine, but I got now a problem with input_line :
> 
> after running open_process_full , i'm first reading all its stdout lines of
> the process until End_of_file is raised, then all its stderr lines using the
> same function.
> 
> It has work fine for few weeks now, but now I found that in some cases
> input_line will block, not raising End_of_file.

I wrote a library exactly for such advanced usage of sub processes:
http://www.ocaml-programming.de/packages/documentation/shell/

For example, to call ocamlc one would do:

open Shell
let stdout = Buffer.create 16 in
let stderr = Buffer.create 16 in
call ~stdout:(to_buffer stdout) ~stderr:(to_buffer stderr) [ cmd "ocamlc" args ]

The Shell library includes the necessary logic to read from multiple
file descriptors (using Unix.select). 

One drawback: Shell works only for Unix (because of Unix.fork). I think that you have
to use multi-threading for a platform-independent solution.

Gerd
-- 
----------------------------------------------------------------------------
Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 45             
64293 Darmstadt     EMail:   gerd@gerd-stolpmann.de
Germany                     
----------------------------------------------------------------------------
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-05-05 13:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-03 12:18 [Caml-list] input_line is blocking Warp
2002-05-03 14:13 ` Oliver Bandel
2002-05-03 17:26 ` Remi VANICAT
2002-05-05 13:09 ` Gerd Stolpmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).