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

dup2 not working under native Windows #7982

Closed
vicuna opened this issue Jan 2, 2003 · 3 comments
Closed

dup2 not working under native Windows #7982

vicuna opened this issue Jan 2, 2003 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 2, 2003

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

Bug description

Full_Name: Thomas Ball
Version: Ocaml 3.06
OS: Windows XP
Submission from: 131.107.3.79 (131.107.3.79)

(* I am trying to redirect stdout to a file under native Windows )
(
but am running into the following problem: the Windows version of )
(
dup2 seems to be incorrect, as the following code shows*)

let main () = begin
let ochan = open_out "test" in
let fd_stdout = Unix.descr_of_out_channel stdout in
let dup_stdout = Unix.dup fd_stdout in

Printf.fprintf stderr "1\n"; flush stderr;

let fd_ochan = Unix.descr_of_out_channel ochan in

Printf.fprintf stderr "2\n"; flush stderr;

Unix.dup2 fd_ochan fd_stdout;

Printf.fprintf stderr "3\n"; flush stderr;

(* following line yields 'Fatal error: exception Sys_error("Bad file
descriptor")' *)
Printf.fprintf stdout "Hello world!";
end ;;

main();;

@vicuna
Copy link
Author

vicuna commented Jan 6, 2003

Comment author: administrator

Fixed 2003-01-06 by XL

@vicuna vicuna closed this as completed Jan 6, 2003
@vicuna
Copy link
Author

vicuna commented Jan 6, 2003

Comment author: administrator

Dear Thomas,

(* I am trying to redirect stdout to a file under native Windows )
(
but am running into the following problem: the Windows version of )
(
dup2 seems to be incorrect, as the following code shows*)

You're correct, the effect of Unix.dup2 was not properly reflected on
the C standard I/O channels underlying OCaml's channels. I have fixed
this in the working sources. Let me know if you need a patch against
OCaml 3.06.

Cheers,

  • Xavier

@vicuna
Copy link
Author

vicuna commented Jan 8, 2003

Comment author: administrator

Thanks, Xavier. We've got a work-around for now, so I'll wait for the next release.

-- Tom

-----Original Message----- 
From: Xavier Leroy [mailto:xavier.leroy@inria.fr] 
Sent: Mon 1/6/2003 7:27 AM 
To: Tom Ball 
Cc: Caml bug tracking system 
Subject: Re: dup2 not working under native Windows (#7982)



Dear Thomas,

> (* I am trying to redirect stdout to a file under native Windows *)
> (* but am running into the following problem: the Windows version of *)
> (* dup2 seems to be incorrect, as the following code shows*)

You're correct, the effect of Unix.dup2 was not properly reflected on
the C standard I/O channels underlying OCaml's channels.  I have fixed
this in the working sources.  Let me know if you need a patch against
OCaml 3.06.

Cheers,

- Xavier

@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