summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-10-20 08:27:44 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-10-20 08:27:44 +0000
commitaa98ed8a09f34fb745cd31d496ab825619d2c82d (patch)
tree1674278c35f87d77b8a4dea496c9f2f57027121f /win32
parenta0ae667081b123207d4d0f2b6e6b7a5597859a57 (diff)
downloadperl-aa98ed8a09f34fb745cd31d496ab825619d2c82d.tar.gz
Code PerlIOWin32_dup - does not fix Win32 problems as :win32 is not
being used yet. p4raw-id: //depot/perlio@12522
Diffstat (limited to 'win32')
-rw-r--r--win32/win32io.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/win32/win32io.c b/win32/win32io.c
index 6152647a74..98eb292286 100644
--- a/win32/win32io.c
+++ b/win32/win32io.c
@@ -297,8 +297,37 @@ PerlIOWin32_close(PerlIO *f)
PerlIO *
PerlIOWin32_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *params)
{
- /* Almost certainly needs more work */
- return PerlIOBase_dup(aTHX_ f, o, params);
+ PerlIOWin32 *os = PerlIOSelf(f,PerlIOWin32);
+ HANDLE proc = GetCurrentProcess();
+ HANDLE new;
+ if (DuplicateHandle(proc, os->h, proc, &new, 0, FALSE, DUPLICATE_SAME_ACCESS))
+ {
+ char mode[8];
+ int fd = win32_open_osfhandle((long) new, PerlIOUnix_oflags(PerlIO_modestr(o,mode)));
+ if (fd >= 0)
+ {
+ f = PerlIOBase_dup(aTHX_ f, o, params);
+ if (f)
+ {
+ PerlIOWin32 *fs = PerlIOSelf(f,PerlIOWin32);
+ fs->h = new;
+ fs->fd = fd;
+ fs->refcnt = 1;
+ fdtable[fd] = fs;
+ if (fd > max_open_fd)
+ max_open_fd = fd;
+ }
+ else
+ {
+ win32_close(fd);
+ }
+ }
+ else
+ {
+ CloseHandle(new);
+ }
+ }
+ return f;
}
PerlIO_funcs PerlIO_win32 = {