From 5ba5d54bd13b2aaa6a25c2b417eec029ae97c60d Mon Sep 17 00:00:00 2001 From: Xavier Leroy <xavier.leroy@inria.fr> Date: Mon, 6 Jan 2003 14:52:57 +0000 Subject: Lorsqu'un file_descr provient d'un fd du CRT, s'en souvenir et en tenir compte quand on fait Unix.dup2 (PR#1509). Remplacement de stdhandle par filedescr_of_fd. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5370 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- otherlibs/win32unix/dup2.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'otherlibs/win32unix/dup2.c') diff --git a/otherlibs/win32unix/dup2.c b/otherlibs/win32unix/dup2.c index c9612620c..4be2d819f 100644 --- a/otherlibs/win32unix/dup2.c +++ b/otherlibs/win32unix/dup2.c @@ -16,6 +16,9 @@ #include <mlvalues.h> #include "unixsupport.h" +extern value win_fd_handle(value); +extern int _dup2(int, int); + CAMLprim value unix_dup2(value fd1, value fd2) { HANDLE oldh, newh; @@ -33,5 +36,8 @@ CAMLprim value unix_dup2(value fd1, value fd2) else CloseHandle(oldh); Descr_kind_val(fd2) = Descr_kind_val(fd1); + /* Reflect the dup2 on the CRT fds, if any */ + if (CRT_fd_val(fd1) != NO_CRT_FD || CRT_fd_val(fd2) != NO_CRT_FD) + _dup2(Int_val(win_fd_handle(fd1)), Int_val(win_fd_handle(fd2))); return Val_unit; } -- cgit v1.2.3-70-g09d2