* 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.
This commit is contained in:
Christopher Faylor 2000-11-03 04:27:03 +00:00
parent 6857eb1b3b
commit bb5d559a73
10 changed files with 59 additions and 22 deletions

View 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> 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. * ntdll.h: Remove IO_COUNTERS definition since it is now in winnt.h.

View File

@ -143,7 +143,7 @@ install_host=@install_host@
all: new-$(DLL_NAME) $(all_host) all_target 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 all_host: new-$(LIB_NAME) cygrun.exe
@ -151,7 +151,7 @@ force:
install: all $(install_host) $(install_target) install: all $(install_host) $(install_target)
$(INSTALL_DATA) new-$(DLL_NAME) $(bindir)/$(DLL_NAME); \ $(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 ; \ $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \
done ; \ done ; \
cd $(srcdir); \ cd $(srcdir); \

26
winsup/cygwin/automode.c Normal file
View File

@ -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);
}

View File

@ -260,7 +260,7 @@ ccalloc (cygheap_types x, DWORD n, DWORD size)
MALLOC_CHECK; MALLOC_CHECK;
c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n * size)); c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n * size));
if (c) if (c)
memset (c->data, 0, size); memset (c->data, 0, n * size);
if (!c) if (!c)
system_printf ("ccalloc returned NULL"); system_printf ("ccalloc returned NULL");
return creturn (x, c, n); return creturn (x, c, n);

View File

@ -20,8 +20,7 @@ class dtable
public: public:
size_t size; size_t size;
dtable () dtable () : first_fd_for_open(3), cnt_need_fixup_before(0) {}
: first_fd_for_open(3), cnt_need_fixup_before(0) {}
void dec_need_fixup_before () void dec_need_fixup_before ()
{ if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; } { if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; }

View File

@ -142,9 +142,6 @@ fhandler_base::get_readahead_into_buffer (char *buf, size_t buflen)
return copied_chars; return copied_chars;
} }
/**********************************************************************/
/* fhandler_base */
/* Record the file name. /* Record the file name.
Filenames are used mostly for debugging messages, and it's hoped that 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 in cases where the name is really required, the filename wouldn't ever
@ -253,6 +250,9 @@ fhandler_base::get_default_fmode (int flags)
size_t nlen = strlen (get_name ()); size_t nlen = strlen (get_name ());
unsigned accflags = ACCFLAGS (flags); unsigned accflags = ACCFLAGS (flags);
for (__cygwin_perfile *pf = perfile_table; pf->name; pf++) for (__cygwin_perfile *pf = perfile_table; pf->name; pf++)
if (!*pf->name && ACCFLAGS (pf->flags) == accflags)
return pf->flags & ~(O_RDONLY | O_WRONLY | O_RDWR);
else
{ {
size_t pflen = strlen (pf->name); size_t pflen = strlen (pf->name);
const char *stem = get_name () + nlen - pflen; const char *stem = get_name () + nlen - pflen;

View File

@ -38,7 +38,7 @@ extern void cygwin_premain3 (int argc, char **argv);
struct __cygwin_perfile struct __cygwin_perfile
{ {
char *name; const char *name;
unsigned flags; unsigned flags;
}; };

View File

@ -219,8 +219,8 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h)
procinfo->pid = n; procinfo->pid = n;
else else
{ {
procinfo->pid = myself->pid;
procinfo->process_state |= PID_IN_USE | PID_EXECED; procinfo->process_state |= PID_IN_USE | PID_EXECED;
procinfo->pid = myself->pid;
} }
break; break;
} }

View File

@ -1250,7 +1250,7 @@ wait_subproc (VOID *)
closed a handle in the children[] array. So, we try looping a couple closed a handle in the children[] array. So, we try looping a couple
of times to stabilize. FIXME - this is not foolproof. Probably, this of times to stabilize. FIXME - this is not foolproof. Probably, this
thread should be responsible for closing the children. */ thread should be responsible for closing the children. */
if (++errloop < 10 && GetLastError () == ERROR_INVALID_HANDLE) if (++errloop < 10)
continue; continue;
system_printf ("wait failed. nchildren %d, wait %d, %E", system_printf ("wait failed. nchildren %d, wait %d, %E",
@ -1261,7 +1261,9 @@ wait_subproc (VOID *)
rc == WAIT_TIMEOUT) rc == WAIT_TIMEOUT)
continue; continue;
else 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; break;
} }

View File

@ -49,10 +49,11 @@ close_all_files (void)
{ {
SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close"); SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK," close");
fhandler_base *fh;
for (int i = 0; i < (int) fdtab.size; i++) 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); fdtab.release (i);
} }