OSDN Git Service

* pinfo.cc (pinfo::init): Reverse order of setting status and pid info in an
authorcgf <cgf>
Fri, 3 Nov 2000 04:27:01 +0000 (04:27 +0000)
committercgf <cgf>
Fri, 3 Nov 2000 04:27:01 +0000 (04:27 +0000)
execed process to avoid a race.
* sigproc.cc (wait_subproc): Print more info when a WFSO error occurs.
* automode.c: New file.
* syscalls.cc (close_all_files): Streamline slightly.
* cygheap.cc (ccalloc): Clear *entire* allocated array.

winsup/cygwin/ChangeLog
winsup/cygwin/Makefile.in
winsup/cygwin/automode.c [new file with mode: 0644]
winsup/cygwin/cygheap.cc
winsup/cygwin/dtable.h
winsup/cygwin/fhandler.cc
winsup/cygwin/include/sys/cygwin.h
winsup/cygwin/pinfo.cc
winsup/cygwin/sigproc.cc
winsup/cygwin/syscalls.cc

index 7ee738e..f0b81ef 100644 (file)
@@ -1,3 +1,12 @@
+Thu Nov  2 23:01:20 2000  Christopher Faylor <cgf@cygnus.com>
+
+       * pinfo.cc (pinfo::init): Reverse order of setting status and pid info
+       in an execed process to avoid a race.
+       * sigproc.cc (wait_subproc): Print more info when a WFSO error occurs.
+       * automode.c: New file.
+       * syscalls.cc (close_all_files): Streamline slightly.
+       * cygheap.cc (ccalloc): Clear *entire* allocated array.
+
 Thu Nov  2 01:58:03 2000  Christopher Faylor <cgf@cygnus.com>
 
        * ntdll.h: Remove IO_COUNTERS definition since it is now in winnt.h.
index 8672759..b65e212 100644 (file)
@@ -143,7 +143,7 @@ install_host=@install_host@
 
 all: new-$(DLL_NAME) $(all_host) all_target
 
-all_target: $(LIBGMON_A) $(LIB_NAME) binmode.o textmode.o
+all_target: $(LIBGMON_A) $(LIB_NAME) automode.o binmode.o textmode.o
 
 all_host: new-$(LIB_NAME) cygrun.exe
 
@@ -151,7 +151,7 @@ force:
 
 install: all $(install_host) $(install_target)
        $(INSTALL_DATA) new-$(DLL_NAME) $(bindir)/$(DLL_NAME); \
-       for i in $(LIB_NAME) $(GMON_START) $(LIBGMON_A) binmode.o textmode.o ; do \
+       for i in $(LIB_NAME) $(GMON_START) $(LIBGMON_A) automode.o binmode.o textmode.o ; do \
            $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \
        done ; \
        cd $(srcdir); \
diff --git a/winsup/cygwin/automode.c b/winsup/cygwin/automode.c
new file mode 100644 (file)
index 0000000..4e9be21
--- /dev/null
@@ -0,0 +1,26 @@
+/* automode.c
+
+   Copyright 2000 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#include <windows.h>
+#include <sys/fcntl.h>
+#include <sys/cygwin.h>
+
+extern int _fmode;
+void
+cygwin_premain0 (int argc, char **argv)
+{
+  static struct __cygwin_perfile pf[] = 
+  {
+    {"", O_RDONLY | O_TEXT},
+    {"", O_WRONLY | O_BINARY},
+    {NULL, 0}
+  };
+  cygwin_internal (CW_PERFILE, pf);
+}
index e583c1e..c6503c4 100644 (file)
@@ -260,7 +260,7 @@ ccalloc (cygheap_types x, DWORD n, DWORD size)
   MALLOC_CHECK;
   c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n * size));
   if (c)
-    memset (c->data, 0, size);
+    memset (c->data, 0, n * size);
   if (!c)
     system_printf ("ccalloc returned NULL");
   return creturn (x, c, n);
index 3851dbf..9ec6dfa 100644 (file)
@@ -20,8 +20,7 @@ class dtable
 public:
   size_t size;
 
-  dtable ()
-    : first_fd_for_open(3), cnt_need_fixup_before(0) {}
+  dtable () : first_fd_for_open(3), cnt_need_fixup_before(0) {}
 
   void dec_need_fixup_before ()
     { if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; }
index d7015b7..3efd81e 100644 (file)
@@ -142,9 +142,6 @@ fhandler_base::get_readahead_into_buffer (char *buf, size_t buflen)
   return copied_chars;
 }
 
-/**********************************************************************/
-/* fhandler_base */
-
 /* Record the file name.
    Filenames are used mostly for debugging messages, and it's hoped that
    in cases where the name is really required, the filename wouldn't ever
@@ -253,14 +250,17 @@ fhandler_base::get_default_fmode (int flags)
       size_t nlen = strlen (get_name ());
       unsigned accflags = ACCFLAGS (flags);
       for (__cygwin_perfile *pf = perfile_table; pf->name; pf++)
-       {
-         size_t pflen = strlen (pf->name);
-         const char *stem = get_name () + nlen - pflen;
-         if (pflen > nlen || (stem != get_name () && !isdirsep (stem[-1])))
-           continue;
-         else if (ACCFLAGS (pf->flags) == accflags && strcasematch (stem, pf->name))
-           return pf->flags & ~(O_RDONLY | O_WRONLY | O_RDWR);
-       }
+       if (!*pf->name && ACCFLAGS (pf->flags) == accflags)
+         return pf->flags & ~(O_RDONLY | O_WRONLY | O_RDWR);
+       else
+         {
+           size_t pflen = strlen (pf->name);
+           const char *stem = get_name () + nlen - pflen;
+           if (pflen > nlen || (stem != get_name () && !isdirsep (stem[-1])))
+             continue;
+           else if (ACCFLAGS (pf->flags) == accflags && strcasematch (stem, pf->name))
+             return pf->flags & ~(O_RDONLY | O_WRONLY | O_RDWR);
+         }
     }
   return __fmode;
 }
index 9bf3e62..b04ecc7 100644 (file)
@@ -38,7 +38,7 @@ extern void cygwin_premain3 (int argc, char **argv);
 
 struct __cygwin_perfile
 {
-  char *name;
+  const char *name;
   unsigned flags;
 };
 
index 850a51b..89dd746 100644 (file)
@@ -219,8 +219,8 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h)
        procinfo->pid = n;
       else
        {
-         procinfo->pid = myself->pid;
          procinfo->process_state |= PID_IN_USE | PID_EXECED;
+         procinfo->pid = myself->pid;
        }
       break;
     }
index c59b67e..e2a3101 100644 (file)
@@ -1250,7 +1250,7 @@ wait_subproc (VOID *)
             closed a handle in the children[] array.  So, we try looping a couple
             of times to stabilize. FIXME - this is not foolproof.  Probably, this
             thread should be responsible for closing the children. */
-         if (++errloop < 10 && GetLastError () == ERROR_INVALID_HANDLE)
+         if (++errloop < 10)
            continue;
 
          system_printf ("wait failed. nchildren %d, wait %d, %E",
@@ -1261,7 +1261,9 @@ wait_subproc (VOID *)
                rc == WAIT_TIMEOUT)
              continue;
            else
-             system_printf ("event[%d] %p, %E", i, events[0]);
+             system_printf ("event[%d] %p, pid %d, dwProcessId %u, progname '%s', %E", i,
+                            events[0], pchildren[i]->pid, pchildren[i]->dwProcessId,
+                            pchildren[i]->progname);
          break;
        }
 
index b6970ff..15bcbfb 100644 (file)
@@ -49,10 +49,11 @@ close_all_files (void)
 {
   SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
 
+  fhandler_base *fh;
   for (int i = 0; i < (int) fdtab.size; i++)
-    if (!fdtab.not_open (i))
+    if ((fh = fdtab[i]) != NULL)
       {
-       fdtab[i]->close ();
+       fh->close ();
        fdtab.release (i);
       }