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 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.
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
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); \
--- /dev/null
+/* 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);
+}
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);
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; }
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
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;
}
struct __cygwin_perfile
{
- char *name;
+ const char *name;
unsigned flags;
};
procinfo->pid = n;
else
{
- procinfo->pid = myself->pid;
procinfo->process_state |= PID_IN_USE | PID_EXECED;
+ procinfo->pid = myself->pid;
}
break;
}
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",
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;
}
{
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);
}