diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 2e850931c..81455c155 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +Fri Aug 25 23:44:48 2000 Christopher Faylor + + * pinfo.h (pinfo): Un-inline release. + * pinfo.cc (pinfo::release): Move here from pinfo.h. + * sigproc.cc (proc_terminate): Remove bogus 'pinfo child' which caused + strange destruction of random regions of memory when destructor was + invoked. + Fri Aug 25 21:25:32 2000 Christopher Faylor * dcrt0.cc (dll_crt0_1): Move set_os_type. diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 08d34dfb2..0d7e785c3 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -197,7 +197,7 @@ pinfo::init (pid_t n, DWORD create, HANDLE in_h) { if (n == myself->pid) { - child = myself; + procinfo = myself; destroy = 0; h = NULL; return; @@ -235,16 +235,16 @@ pinfo::init (pid_t n, DWORD create, HANDLE in_h) { if (create) __seterrno (); - child = NULL; + procinfo = NULL; return; } ProtectHandle1 (h, pinfo_shared_handle); - child = (_pinfo *) MapViewOfFile (h, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); + procinfo = (_pinfo *) MapViewOfFile (h, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); - if (child->process_state & PID_EXECED) + if (procinfo->process_state & PID_EXECED) { - pid_t realpid = child->pid; + pid_t realpid = procinfo->pid; debug_printf ("execed process windows pid %d, cygwin pid %d", n, realpid); release (); if (realpid == n) @@ -255,16 +255,29 @@ pinfo::init (pid_t n, DWORD create, HANDLE in_h) if (created) { if (!(create & PID_EXECED)) - child->pid = n; + procinfo->pid = n; else { - child->pid = myself->pid; - child->process_state |= PID_IN_USE | PID_EXECED; + procinfo->pid = myself->pid; + procinfo->process_state |= PID_IN_USE | PID_EXECED; } } destroy = 1; } +void +pinfo::release () +{ + if (h) + { +#ifdef DEBUGGING + if (((DWORD) procinfo & 0x77000000) == 0x61000000) try_to_debug (); +#endif + UnmapViewOfFile (procinfo); + ForceCloseHandle1 (h, pinfo_shared_handle); + h = NULL; + } +} /* DOCTOOL-START diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index f84659813..ef8dffff2 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -114,37 +114,29 @@ public: class pinfo { HANDLE h; - _pinfo *child; + _pinfo *procinfo; int destroy; public: void init (pid_t n, DWORD create = 0, HANDLE h = NULL); - pinfo () {} - pinfo (_pinfo *x): child (x) {} + pinfo (): h (NULL), procinfo (0), destroy (0) {} + pinfo (_pinfo *x): procinfo (x) {} pinfo (pid_t n) {init (n);} pinfo (pid_t n, int create) {init (n, create);} - void release () - { - if (h) - { - UnmapViewOfFile (child); - ForceCloseHandle1 (h, pinfo_shared_handle); - h = NULL; - } - } + void release (); ~pinfo () { - if (destroy && child) + if (destroy && procinfo) release (); } - _pinfo *operator -> () const {return child;} - int operator == (pinfo *x) const {return x->child == child;} - int operator == (pinfo &x) const {return x.child == child;} - int operator == (void *x) const {return child == x;} - int operator == (int x) const {return (int) child == (int) x;} - int operator == (char *x) const {return (char *) child == x;} - _pinfo *operator * () const {return child;} - operator _pinfo * () const {return child;} + _pinfo *operator -> () const {return procinfo;} + int operator == (pinfo *x) const {return x->procinfo == procinfo;} + int operator == (pinfo &x) const {return x.procinfo == procinfo;} + int operator == (void *x) const {return procinfo == x;} + int operator == (int x) const {return (int) procinfo == (int) x;} + int operator == (char *x) const {return (char *) procinfo == x;} + _pinfo *operator * () const {return procinfo;} + operator _pinfo * () const {return procinfo;} // operator bool () const {return (int) h;} void remember () {destroy = 0; proc_subproc (PROC_ADDCHILD, (DWORD) this);} HANDLE shared_handle () {return h;} diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 0d573fc98..f9f149851 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -499,13 +499,12 @@ proc_terminate (void) zombies[i]->hProcess = NULL; } zombies[i]->process_state = PID_NOT_IN_USE; /* CGF FIXME - still needed? */ - // zombies[i].release(); // FIXME: this breaks older gccs for some reason + zombies[i].release(); // FIXME: this breaks older gccs for some reason } /* Disassociate my subprocesses */ for (i = 0; i < nchildren; i++) { - pinfo child; /* CGF FIXME */ if (pchildren[i]->process_state == PID_NOT_IN_USE) continue; // Should never happen if (!pchildren[i]->hProcess) @@ -530,7 +529,7 @@ proc_terminate (void) pchildren[i]->process_state |= PID_ORPHANED; } } - // pchildren[i].release (); // FIXME: this breaks older gccs for some reason + pchildren[i].release (); // FIXME: this breaks older gccs for some reason } nchildren = nzombies = 0;