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>2003-01-05 06:01:27 +0300
committerChristopher Faylor <me@cgf.cx>2003-01-05 06:01:27 +0300
commit9c18893bfe782c34700c49d37344f2ad58c73958 (patch)
treec772ee41925386c16b44b0f0046641886f1732a7
parentb17ab27868d2b5d0a7489c745dde333082e86a1b (diff)
Replace is_fs_device with is_fs_special throughout.
* Makefile.in (DLL_OFILES): Add fhandler_fifo.o. * devices.h (fh_devices): Renumber some minor numbers to fit in 8 bits. * dtable.cc (dtable::build_fhandler): Handle FH_FIFO. Set errno to ENODEV if device not found. * dtable::find_fifo: Define new function. * dtable.h (dtable::find_fifo): Declare new function. * fhandler.cc (fhandler_base::device_access_denied): Fix O_RDONLY test. (fhandler_base::write): Use output file handle for writing. (fhandler_base::fstat): Use is_fs_special rather than is_fs_device. * fhandler.h (fhandler_base::is_fs_special): Rename from is_fs_device. (fhandler_pipe): Make private elements protected so that fhandler_fifo can use them too. (fhandler_pipe::create): New function derived from make_pipe. (fhandler_fifo): Add more needed elements. (fhandler_pty_master::slave): Add to track slave device. (fhandler_pty_master::get_unit): Define. * fhandler_tty.cc (fhandler_tty_master::init): Register slave device. (fhandler_pty_master::open): Ditto. (symlink_info::parse_device): Handle fifo specially. * pinfo.cc (_pinfo::commune_recv): Initial fifo implementation. (_pinfo::commune_send): Ditto. * pinfo.h (picom): Add PICOM_FIFO. * pipe.cc (fhandler_pipe::close): Close input handle here specifically. (fhandler_pipe::create): Rename from make_pipe. Create fhandlers rather than fds. (pipe): Use fhandler_pipe::create to create pipe. (_pipe): Ditto. * syscalls.cc (mknod): Accommodate fifos.
-rw-r--r--winsup/cygwin/pinfo.cc62
1 files changed, 55 insertions, 7 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 3c5af4bce..d59a0dada 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -13,6 +13,7 @@ details. */
#include <time.h>
#include <errno.h>
#include <limits.h>
+#include <stdarg.h>
#include "security.h"
#include "fhandler.h"
#include "path.h"
@@ -28,6 +29,8 @@ details. */
#include "ntdll.h"
#include "cygthread.h"
#include "shared_info.h"
+#include "cygheap.h"
+#include "fhandler.h"
static char NO_COPY pinfo_dummy[sizeof (_pinfo)] = {0};
@@ -304,11 +307,35 @@ _pinfo::commune_recv ()
sigproc_printf ("WriteFile arg %d failed, %E", a - __argv);
break;
}
- if (!WriteFile (__tothem, "", 1, &nr, NULL))
- {
- sigproc_printf ("WriteFile null failed, %E");
- break;
- }
+ if (!WriteFile (__tothem, "", 1, &nr, NULL))
+ {
+ sigproc_printf ("WriteFile null failed, %E");
+ break;
+ }
+ break;
+ }
+ case PICOM_FIFO:
+ {
+ int formic;
+ if (!ReadFile (__fromthem, &formic, sizeof formic, &nr, NULL)
+ || nr != sizeof formic)
+ {
+ /* __seterrno ();*/ // this is run from the signal thread, so don't set errno
+ goto out;
+ }
+ fhandler_fifo *fh = cygheap->fdtab.find_fifo ((ATOM) formic);
+ if (!WriteFile (__tothem, &(fh->get_handle ()), sizeof (HANDLE), &nr, NULL))
+ {
+ /*__seterrno ();*/ // this is run from the signal thread, so don't set errno
+ sigproc_printf ("WriteFile read handle failed, %E");
+ }
+
+ if (!WriteFile (__tothem, &(fh->get_output_handle ()), sizeof (HANDLE), &nr, NULL))
+ {
+ /*__seterrno ();*/ // this is run from the signal thread, so don't set errno
+ sigproc_printf ("WriteFile write handle failed, %E");
+ }
+ break;
}
}
@@ -322,12 +349,15 @@ out:
#define PIPEBUFSIZE (16 * sizeof (DWORD))
commune_result
-_pinfo::commune_send (DWORD code)
+_pinfo::commune_send (DWORD code, ...)
{
HANDLE fromthem = NULL, tome = NULL;
HANDLE fromme = NULL, tothem = NULL;
DWORD nr;
commune_result res;
+ va_list args;
+
+ va_start (args, code);
res.s = NULL;
res.n = 0;
@@ -359,6 +389,17 @@ _pinfo::commune_send (DWORD code)
goto err;
}
+ switch (code)
+ {
+ case PICOM_FIFO:
+ {
+ int formic = va_arg (args, int);
+ if (WriteFile (tothem, &formic, sizeof formic, &nr, NULL) != sizeof formic)
+ goto err;
+ break;
+ }
+ }
+
if (sig_send (this, __SIGCOMMUNE))
goto err;
@@ -407,6 +448,12 @@ _pinfo::commune_send (DWORD code)
}
res.n = n;
break;
+ case PICOM_FIFO:
+ if (n != sizeof (res.handles)
+ || !ReadFile (fromthem, res.handles, sizeof (res.handles), &nr, NULL)
+ || nr != n)
+ goto err;
+ break;
}
CloseHandle (tothem);
CloseHandle (fromthem);
@@ -421,7 +468,8 @@ err:
CloseHandle (tothem);
if (fromme)
CloseHandle (fromme);
- res.n = 0;
+ memset (&res, 0, sizeof (res));
+
out:
myself->hello_pid = 0;
LeaveCriticalSection (&lock);