From 28c8ae66d5ab61600f7d32d8aabbf9dfbfb3d9f8 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 30 Apr 2012 15:38:45 +0000 Subject: * fhandler.h (PIPE_ADD_PID): Define new flag. * pipe.cc (fhandler_pipe::create): Don't indiscriminately add process id to every pipe since some pipe names (fifo, tty) don't need it. * sigproc.cc (sigproc_init): Pass PIPE_ADD_PID to fhandler_pipe::create to ensure that pid is always part of sigwait pipe name. --- winsup/cygwin/ChangeLog | 10 +++++++++- winsup/cygwin/fhandler.h | 8 ++++++-- winsup/cygwin/pipe.cc | 11 ++++++++--- winsup/cygwin/sigproc.cc | 3 ++- 4 files changed, 25 insertions(+), 7 deletions(-) (limited to 'winsup') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 02f77d7b0..eab3fc556 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,6 +1,14 @@ +2012-04-30 Christopher Faylor + + * fhandler.h (PIPE_ADD_PID): Define new flag. + * pipe.cc (fhandler_pipe::create): Don't indiscriminately add process + id to every pipe since some pipe names (fifo, tty) don't need it. + * sigproc.cc (sigproc_init): Pass PIPE_ADD_PID to fhandler_pipe::create + to ensure that pid is always part of sigwait pipe name. + 2012-04-28 Christopher Faylor - * environ.cc (struct parse_thing): Add temporary (?) "pipe_byte" option. + * environ.cc (struct parse_thing): Add "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 diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index fcb460e9e..2a639cda8 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -14,8 +14,8 @@ details. */ #include "tty.h" /* fcntl flags used only internaly. */ -#define O_NOSYMLINK 0x080000 -#define O_DIROPEN 0x100000 +#define O_NOSYMLINK 0x080000 +#define O_DIROPEN 0x100000 /* newlib used to define O_NDELAY differently from O_NONBLOCK. Now it properly defines both to be the same. Unfortunately, we have to @@ -36,6 +36,10 @@ details. */ so small. http://cygwin.com/ml/cygwin/2011-03/msg00541.html */ #define DEFAULT_PIPEBUFSIZE PREFERRED_IO_BLKSIZE +/* Used for fhandler_pipe::create. Use an available flag which will + never be used in Cygwin for this function. */ +#define PIPE_ADD_PID PIPE_ACCESS_OUTBOUND + extern const char *windows_device_names[]; extern struct __cygwin_perfile *perfile_table; #define __fmode (*(user_data->fmode_ptr)) diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index e8d15915f..e5909c4d4 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -211,9 +211,8 @@ 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-%u-", - &cygheap->installation_key, - GetCurrentProcessId ()); + size_t len = __small_sprintf (pipename, PIPE_INTRO "%S-", + &cygheap->installation_key); DWORD pipe_mode = PIPE_READMODE_BYTE; if (!name) pipe_mode |= pipe_byte ? PIPE_TYPE_BYTE : PIPE_TYPE_MESSAGE; @@ -223,6 +222,12 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w, pipe_mode |= PIPE_TYPE_MESSAGE; } + if (!name || (open_mode &= PIPE_ADD_PID)) + { + len += __small_sprintf (pipename + len, "%u-", GetCurrentProcessId ()); + open_mode &= ~PIPE_ADD_PID; + } + open_mode |= PIPE_ACCESS_INBOUND; /* Retry CreateNamedPipe as long as the pipe name is in use. diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 93fc75b11..c9a76d85f 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -529,7 +529,8 @@ sigproc_init () char char_sa_buf[1024]; PSECURITY_ATTRIBUTES sa = sec_user_nih ((PSECURITY_ATTRIBUTES) char_sa_buf, cygheap->user.sid()); DWORD err = fhandler_pipe::create (sa, &my_readsig, &my_sendsig, - sizeof (sigpacket), "sigwait", 0); + sizeof (sigpacket), "sigwait", + PIPE_ADD_PID); if (err) { SetLastError (err); -- cgit v1.2.3