Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-04-22 17:58:09 +0400
committerChristopher Faylor <me@cgf.cx>2005-04-22 17:58:09 +0400
commitfb201f9270852972b28ceee21bcc2cfbf2e89e15 (patch)
tree4cedce7b18d548c5166872d627c56eb5df0cbcd3 /winsup/cygwin/fhandler_fifo.cc
parentb13aa0048929834caaba6aba47e70125bc436e31 (diff)
* fhandler.cc (fhandler_base::read): Remove unused signal state tweaks.
* fhandler.h (fhandler_pipe::create_selectable): Declare. (fhandler_fifo::close_one_end): Declare. * fhandler_fifo.cc (fhandler_fifo::close_one_end): Define. (fhandler_fifo::open_not_mine): Use close_one_end to close appropriate end of pipe. * pinfo.cc (_pinfo::commune_recv): Ditto. * pipe.cc (fhandler_pipe::create_selectable): Rename from create_selectable_pipe. Reorganize. (fhandler_pipe::create): Use create_selectable.
Diffstat (limited to 'winsup/cygwin/fhandler_fifo.cc')
-rw-r--r--winsup/cygwin/fhandler_fifo.cc41
1 files changed, 23 insertions, 18 deletions
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index b654dc2dd..42b185102 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -67,14 +67,30 @@ fhandler_fifo::close ()
}
#define DUMMY_O_RDONLY 4
+
+void
+fhandler_fifo::close_one_end ()
+{
+ int testflags = (get_flags () & (O_RDWR | O_WRONLY | O_APPEND)) ?: DUMMY_O_RDONLY;
+ static int flagtypes[] = {DUMMY_O_RDONLY | O_RDWR, O_WRONLY | O_APPEND | O_RDWR};
+ HANDLE *handles[2] = {&(get_handle ()), &(get_output_handle ())};
+ for (int i = 0; i < 2; i++)
+ if (!(testflags & flagtypes[i]))
+ {
+ CloseHandle (*handles[i]);
+ *handles[i] = NULL;
+ }
+ else if (i == 0 && !read_state)
+ {
+ create_read_state (2);
+ need_fork_fixup (true);
+ }
+}
int
fhandler_fifo::open_not_mine (int flags)
{
winpids pids;
- static int flagtypes[] = {DUMMY_O_RDONLY | O_RDWR, O_WRONLY | O_APPEND | O_RDWR};
- HANDLE *usehandles[2] = {&(get_handle ()), &(get_output_handle ())};
int res = 0;
- int testflags = (flags & (O_RDWR | O_WRONLY | O_APPEND)) ?: DUMMY_O_RDONLY;
for (unsigned i = 0; i < pids.npids; i++)
{
@@ -109,22 +125,11 @@ fhandler_fifo::open_not_mine (int flags)
}
}
- for (int i = 0; i < 2; i++)
- if (!(testflags & flagtypes[i]))
- CloseHandle (r.handles[i]);
- else
- {
- *usehandles[i] = r.handles[i];
-
- if (i == 0)
- {
- read_state = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
- need_fork_fixup (true);
- }
- }
-
- res = 1;
+ set_io_handle (r.handles[0]);
+ set_output_handle (r.handles[1]);
set_flags (flags);
+ close_one_end ();
+ res = 1;
goto out;
}