Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/Makefile.in,v
retrieving revision 1.98
diff -u -r1.98 Makefile.in
--- Makefile.in	1 Aug 2002 16:20:31 -0000	1.98
+++ Makefile.in	9 Aug 2002 05:05:57 -0000
@@ -135,7 +135,8 @@
 	select.o shared.o shm.o shortcut.o signal.o sigproc.o smallprint.o \
 	spawn.o strace.o strsep.o sync.o syscalls.o sysconf.o syslog.o \
 	termios.o thread.o times.o tty.o uinfo.o uname.o v8_regexp.o \
-	v8_regerror.o v8_regsub.o wait.o wincap.o window.o \
+	v8_regerror.o v8_regsub.o wait.o wincap.o window.o \
+	fhandler_fifo.o \
 	$(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS)
 
 GMON_OFILES:=gmon.o mcount.o profil.o
Index: dtable.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dtable.cc,v
retrieving revision 1.99
diff -u -r1.99 dtable.cc
--- dtable.cc	3 Jul 2002 18:02:53 -0000	1.99
+++ dtable.cc	9 Aug 2002 05:05:59 -0000
@@ -282,6 +282,16 @@
       set_errno (pc.error);
       return NULL;
     }
+    
+  /*  check fifo */
+  if (handle == NULL && pc.exists() && !pc.isdir())
+    {
+     if (strncmp(pc.normalized_path,"/fifo/",6) == 0) 
+       {
+	  fhandler_base *fh = build_fhandler  (fd, FH_FIFO, name,pc,pc.get_unitn());
+	  return fh;
+       }
+    } /* NULL handle */
 
   if (!pc.exists () && handle)
     pc.fillin (handle);
@@ -372,6 +382,11 @@
       case FH_OSS_DSP:
 	fh = cnew (fhandler_dev_dsp) ();
 	break;
+	
+      case FH_FIFO:
+      	fh = cnew (fhandler_fifo) (NULL);
+      	break;
+	
       case FH_PROC:
 	fh = cnew (fhandler_proc) ();
 	break;
Index: fhandler.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler.h,v
retrieving revision 1.133
diff -u -r1.133 fhandler.h
--- fhandler.h	2 Aug 2002 02:10:24 -0000	1.133
+++ fhandler.h	9 Aug 2002 05:06:00 -0000
@@ -74,8 +74,10 @@
   FH_PROC    = 0x0000001a,      /* /proc */
   FH_REGISTRY =0x0000001b,      /* /proc/registry */
   FH_PROCESS = 0x0000001c,      /* /proc/<n> */
+  
+  FH_FIFO = 	 0x0000001d,
 
-  FH_NDEV    = 0x0000001d,      /* Maximum number of devices */
+  FH_NDEV    = 0x0000001e,      /* Maximum number of devices */
   FH_DEVMASK = 0x00000fff,	/* devices live here */
   FH_BAD     = 0xffffffff
 };
@@ -1227,5 +1229,73 @@
 };
 
 int __stdcall set_console_state_for_spawn ();
+
+
+class fifoshared
+{
+  public:
+  size_t data_offset;
+  unsigned int readers, writers;
+  /*set to 1 when the writer has written the last of it's buffer */
+  unsigned char eow;     
+  size_t buffer_length;
+  size_t buffer_offset;
+  size_t data_length;
+  unsigned int pipeactive;
+};
+
+class fhandler_fifo: public fhandler_base
+{
+private:
+  int is_open;
+  int reader, writer;
+
+  HANDLE filemap;
+  HANDLE readreadyevent;
+  HANDLE writingmutex;
+  HANDLE writedoneevent;
+  HANDLE readmutex;
+  HANDLE datamutex;
+  void *filedata;
+  unsigned int fifoaccess;
+  /* this may mean that multiple fifos at the max path length with similar prefixes 
+   * collide. WIN32 limits us here, so the answer is don't do that! aka. Tough. */
+  char filemapname[MAX_PATH];
+  char rrname[MAX_PATH];
+  char rmname[MAX_PATH];
+  char wmname[MAX_PATH];
+  char wdname[MAX_PATH];
+  char rsname[MAX_PATH];
+  char wsname[MAX_PATH];
+  char dmname[MAX_PATH];
+  class fifoshared *guts;
+
+public:
+  fhandler_fifo (const char *name);
+
+  int open (const char *path, int flags, mode_t mode = 0);
+  virtual int open (path_conv* real_path, int flags, mode_t mode);
+  virtual int dup (fhandler_base *child);
+  virtual off_t lseek (off_t offset, int whence);
+  virtual int close ();
+
+  virtual int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3))); 
+  virtual int write (const void *ptr, size_t len);
+
+//  virtual void fixup_before_fork_exec (DWORD);
+  void fixup_after_fork (HANDLE);
+  void fixup_after_exec (HANDLE parent) { fixup_after_fork (parent); }
+
+  // I need the fixup_after_fork stuff
+
+//  int lock (int, struct flock *);
+//  int fstat (struct stat *buf);
+
+//  HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, off_t off);
+//  int munmap (HANDLE h, caddr_t addr, size_t len);
+//  int msync (HANDLE h, caddr_t addr, size_t len, int flags);
+//  BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
+//                              DWORD size, void *address);
+};
 
 #endif /* _FHANDLER_H_ */
Index: syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.223
diff -u -r1.223 syscalls.cc
--- syscalls.cc	2 Aug 2002 11:00:18 -0000	1.223
+++ syscalls.cc	9 Aug 2002 05:06:07 -0000
@@ -1931,6 +1931,35 @@
   return 0;
 }
 
+extern "C" int 
+mkfifo ( const char *pathname, mode_t mode )
+{
+	/* create a file on /fifo/ and symlink to it */
+	FILE *tempfile;
+	int len = strlen(pathname);
+	char* str = (char*) malloc(len+7);
+	strcpy(str,"/fifo/");
+	strcat(str,pathname);
+	
+	for (int i = 6; i < len+6; i++) {
+		char c = str[i];
+		if (c == '/')
+			str[i] = '_';
+	}
+	if ((tempfile=fopen(str,"w"))==NULL)
+     	{
+       		system_printf("error opening %s\n",str);
+       		set_errno (EIO);
+       		return -1;
+     	}
+     	fclose(tempfile);
+     	symlink(str,pathname);
+     	free(str);
+  return 0;
+
+}
+
+
 /* mknod was the call to create directories before the introduction
    of mkdir in 4.2BSD and SVR3.  Use of mknod required superuser privs
    so the mkdir command had to be setuid root.
@@ -1940,17 +1969,14 @@
 extern "C" int
 mknod (const char *_path, mode_t mode, dev_t dev)
 {
+  if (mode & S_IFIFO)
+  {
+    return mkfifo (_path, mode | (!S_IFIFO));
+  }
+  else
   set_errno (ENOSYS);
   return -1;
 }
-
-extern "C" int
-mkfifo (const char *_path, mode_t mode)
-{
-  set_errno (ENOSYS);
-  return -1;
-}
-
 /* seteuid: standards? */
 extern "C" int
 seteuid32 (__uid32_t uid)

