]> sourceware.org Git - newlib-cygwin.git/commitdiff
* pinfo.cc (pinfo::init): Reverse order of setting status and pid info in an
authorChristopher Faylor <me@cgf.cx>
Fri, 3 Nov 2000 04:27:03 +0000 (04:27 +0000)
committerChristopher Faylor <me@cgf.cx>
Fri, 3 Nov 2000 04:27:03 +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 7ee738e94214c1ebb283eabbe263d664fdde1efe..f0b81ef8c7b8ee871046dadef91ba0a5f88969c2 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 8672759d803aeb34e45de298d83a8f70be0cf8b5..b65e212f58f058bb9099a49472db5f6bb44338b4 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 e583c1efce700807ab88c81406d269dd91f19d11..c6503c41b17430f7ac45e8281457c1fefb9b0051 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 3851dbfae352cb44abc6a9833dc7c0a09791ba44..9ec6dfae6bc8a2f98c35507b3d9bdcb05a0993d8 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 d7015b7ab343567ec5c193f58e5b9e28e38351bf..3efd81efb9a7bd97d85c7d4ae7599c2bd5095657 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 9bf3e62f974efd8040b6991660054cb493fa1c24..b04ecc7425c2b338bf3669297ce68fbbc1c8cba7 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 850a51b85c26e67deaee00224d7686a808a441b6..89dd7469ef49c0fe6d3bbd33116776c239cbfd2d 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 c59b67ed1ddb3aae78dfa1558a40d140cf670836..e2a310120afc0665c5e1bb2fa4cae436ee6a0e46 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 b6970ff71f64e8e55bb46ade020c2424d89fb1d5..15bcbfbd119ea1d8f759461a0feebb9449b6b6e8 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);
       }
 
This page took 0.046697 seconds and 5 git commands to generate.