From 8528ecbde8282bb640a49b531408cc783f05966a Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Tue, 1 Jan 2008 18:51:23 +0000 Subject: * newsym: First stab at understanding data as well as functions. * pipe.cc (fhandler_pipe::init): Move more intelligence here. (fhandler_pipe::create): Simplify based on above change. * tty.cc (tty_list::allocate): Remove non-NT code. --- winsup/cygwin/pipe.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'winsup/cygwin/pipe.cc') diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index a6e4fff56..4774ef352 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -156,7 +156,7 @@ out: #define WINPIPE "\\\\.\\pipe\\" void -fhandler_pipe::init (HANDLE f, DWORD a, mode_t bin) +fhandler_pipe::init (HANDLE f, DWORD a, mode_t mode) { // FIXME: Have to clean this up someday if (!*get_win32_name () && get_name ()) @@ -181,7 +181,9 @@ fhandler_pipe::init (HANDLE f, DWORD a, mode_t bin) f = ps.ret_handle; } - fhandler_base::init (f, a, bin); + fhandler_base::init (f, a, mode); + if (mode & O_NOINHERIT) + close_on_exec (true); setup_overlapped (); } @@ -424,25 +426,22 @@ fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode) { HANDLE r, w; SECURITY_ATTRIBUTES *sa = (mode & O_NOINHERIT) ? &sec_none_nih : &sec_none; - int res = -1; + int res; int ret = create_selectable (sa, r, w, psize); if (ret) - __seterrno_from_win_error (ret); + { + __seterrno_from_win_error (ret); + res = -1; + } else { fhs[0] = (fhandler_pipe *) build_fh_dev (*piper_dev); fhs[1] = (fhandler_pipe *) build_fh_dev (*pipew_dev); - int binmode = mode & O_TEXT ?: O_BINARY; - fhs[0]->init (r, FILE_CREATE_PIPE_INSTANCE | GENERIC_READ, binmode); - fhs[1]->init (w, FILE_CREATE_PIPE_INSTANCE | GENERIC_WRITE, binmode); - if (mode & O_NOINHERIT) - { - fhs[0]->close_on_exec (true); - fhs[1]->close_on_exec (true); - } - + mode |= mode & O_TEXT ?: O_BINARY; + fhs[0]->init (r, FILE_CREATE_PIPE_INSTANCE | GENERIC_READ, mode); + fhs[1]->init (w, FILE_CREATE_PIPE_INSTANCE | GENERIC_WRITE, mode); res = 0; } -- cgit v1.2.3