Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open_process_in does not work properly with threads (???) #2828

Closed
vicuna opened this issue Jul 4, 2001 · 2 comments
Closed

open_process_in does not work properly with threads (???) #2828

vicuna opened this issue Jul 4, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 4, 2001

Original bug ID: 425
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hello, this is a bug report of

Objective Caml version 3.01+4 (2001-06-18).

(Am I encouraged to post reports of +n versions ?)

The following simple "folk-exec-cat" with thread does not work
correctly in this version of O'Caml. The program receives EOF
before cat finishes printing all the content.
I verified that with the official version of ocaml 3.01,
the program works correctly.

(* compile:
ocamlc -thread -custom -o threadtest unix.cma threads.cma threadtest.ml *)

open ThreadUnix

let cat_some_long_file = (* Works for cristal machines *)
"cat /net/pauillac/infosystems/www/caml/users_comments-eng.html"

let ic = open_process_in cat_some_long_file
let _ =
try
while true do
prerr_endline (input_line ic)
done
with _ ->
close_in ic

--
JPF

@vicuna
Copy link
Author

vicuna commented Jul 5, 2001

Comment author: administrator

Hello, this is a bug report of
Objective Caml version 3.01+4 (2001-06-18).
(Am I encouraged to post reports of +n versions ?)

Yes! Very much encouraged! It's better to catch bugs before the releases...

The following simple "folk-exec-cat" with thread does not work
correctly in this version of O'Caml. The program receives EOF
before cat finishes printing all the content.
I verified that with the official version of ocaml 3.01,
the program works correctly.

Interesting. The new thread-safe reimplementation of the Unix module
(provided by the bytecode threads library) is indeed buggy, because
the process forked by open_process_* has its standard descriptors
still in non-blocking mode, which causes problems with most programs.

Actually, this exposes another bug that has been here for a long time:
when a threaded program calls Unix.exec*, the standard descriptors are
left in non-blocking mode, with equally bad consequences.

I have fixed both issues by simply resetting the standard descriptors
to blocking mode in the exec* functions, which are also called by
open_process_*.

Thanks,

  • Xavier

@vicuna
Copy link
Author

vicuna commented Jul 5, 2001

Comment author: administrator

Fixed 2001-07-04 by XL.

@vicuna vicuna closed this as completed Jul 5, 2001
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant