aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/Makefile.in4
-rw-r--r--winsup/cygwin/automode.c26
-rw-r--r--winsup/cygwin/cygheap.cc2
-rw-r--r--winsup/cygwin/dtable.h3
-rw-r--r--winsup/cygwin/fhandler.cc22
-rw-r--r--winsup/cygwin/include/sys/cygwin.h2
-rw-r--r--winsup/cygwin/pinfo.cc2
-rw-r--r--winsup/cygwin/sigproc.cc6
-rw-r--r--winsup/cygwin/syscalls.cc5
10 files changed, 59 insertions, 22 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 7ee738e..f0b81ef 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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.
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 8672759..b65e212 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -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
index 0000000..4e9be21
--- /dev/null
+++ b/winsup/cygwin/automode.c
@@ -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);
+}
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index e583c1e..c6503c4 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -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);
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index 3851dbf..9ec6dfa 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -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; }
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index d7015b7..3efd81e 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -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;
}
diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h
index 9bf3e62..b04ecc7 100644
--- a/winsup/cygwin/include/sys/cygwin.h
+++ b/winsup/cygwin/include/sys/cygwin.h
@@ -38,7 +38,7 @@ extern void cygwin_premain3 (int argc, char **argv);
struct __cygwin_perfile
{
- char *name;
+ const char *name;
unsigned flags;
};
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 850a51b..89dd746 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -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;
}
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index c59b67e..e2a3101 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -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;
}
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index b6970ff..15bcbfb 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -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);
}