* 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.
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user