diff options
author | Christopher Faylor <me@cgf.cx> | 2008-01-01 21:51:23 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2008-01-01 21:51:23 +0300 |
commit | 8528ecbde8282bb640a49b531408cc783f05966a (patch) | |
tree | 9103839932b901446ffd5b348a34e1f84099ce20 /winsup/cygwin/pipe.cc | |
parent | b918632a2aa389cd788634b3f08a81e66193b016 (diff) |
* 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.
Diffstat (limited to 'winsup/cygwin/pipe.cc')
-rw-r--r-- | winsup/cygwin/pipe.cc | 25 |
1 files changed, 12 insertions, 13 deletions
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; } |