summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/pipe.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-04-28 19:49:58 +0000
committerChristopher Faylor <me@cgf.cx>2012-04-28 19:49:58 +0000
commitea17849f8b0f2280f259ad24fd5e8891864f4cf6 (patch)
tree2edaaf1feaa4dff84a4babd342a71535f2221d71 /winsup/cygwin/pipe.cc
parent2875f31af2aa5fd1adac8a43d823f20125289c6c (diff)
downloadcygnal-ea17849f8b0f2280f259ad24fd5e8891864f4cf6.tar.gz
cygnal-ea17849f8b0f2280f259ad24fd5e8891864f4cf6.tar.bz2
cygnal-ea17849f8b0f2280f259ad24fd5e8891864f4cf6.zip
* environ.cc (struct parse_thing): Add temporary (?) "pipe_byte" option.
* globals.cc (pipe_byte): Declare. * pipe.cc (fhandler_pipe::create): Use current process id in pipe name rather than pid for simple name collision avoidance. Do this only once to avoid extra overhead when a busy pipe is found. Honor pipe_byte to create non-message pipes if set. * sigproc.cc (sigproc_init): Use a specific name for the signal pipe.
Diffstat (limited to 'winsup/cygwin/pipe.cc')
-rw-r--r--winsup/cygwin/pipe.cc26
1 files changed, 17 insertions, 9 deletions
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 52f2ba058..e8d15915f 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -211,10 +211,17 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
psize = DEFAULT_PIPEBUFSIZE;
char pipename[MAX_PATH];
- const size_t len = __small_sprintf (pipename, PIPE_INTRO "%S-",
- &cygheap->installation_key);
- if (name)
- strcpy (pipename + len, name);
+ const size_t len = __small_sprintf (pipename, PIPE_INTRO "%S-%u-",
+ &cygheap->installation_key,
+ GetCurrentProcessId ());
+ DWORD pipe_mode = PIPE_READMODE_BYTE;
+ if (!name)
+ pipe_mode |= pipe_byte ? PIPE_TYPE_BYTE : PIPE_TYPE_MESSAGE;
+ else
+ {
+ strcpy (pipename + len, name);
+ pipe_mode |= PIPE_TYPE_MESSAGE;
+ }
open_mode |= PIPE_ACCESS_INBOUND;
@@ -226,10 +233,12 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
{
static volatile ULONG pipe_unique_id;
if (!name)
- __small_sprintf (pipename + len, "pipe-%p-%p", myself->pid,
- InterlockedIncrement ((LONG *) &pipe_unique_id));
+ __small_sprintf (pipename + len, "pipe-%p",
+ InterlockedIncrement ((LONG *) &pipe_unique_id));
- debug_printf ("CreateNamedPipe: name %s, size %lu", pipename, psize);
+ debug_printf ("name %s, size %lu, mode %s", pipename, psize,
+ (pipe_mode & PIPE_TYPE_MESSAGE)
+ ? "PIPE_TYPE_MESSAGE" : "PIPE_TYPE_BYTE");
/* Use CreateNamedPipe instead of CreatePipe, because the latter
returns a write handle that does not permit FILE_READ_ATTRIBUTES
@@ -246,8 +255,7 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
definitely required for pty handling since fhandler_pty_master
writes to the pipe in chunks, terminated by newline when CANON mode
is specified. */
- *r = CreateNamedPipe (pipename, open_mode,
- PIPE_TYPE_MESSAGE | PIPE_READMODE_BYTE, 1, psize,
+ *r = CreateNamedPipe (pipename, open_mode, pipe_mode, 1, psize,
psize, NMPWAIT_USE_DEFAULT_WAIT, sa_ptr);
if (*r != INVALID_HANDLE_VALUE)