diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 22 | ||||
-rw-r--r-- | winsup/cygwin/debug.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_termios.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 19 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/signal.cc | 31 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.h | 1 |
8 files changed, 51 insertions, 37 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9a5de4d70..71694c9dc 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,23 @@ +2005-02-26 Christopher Faylor <cgf@timesys.com> + + * debug.cc (delete_handle): Report on handle value in debugging output. + + * pinfo.h (_pinfo::exists): Declare "new" function. + (_pinfo::kill): Ditto. + * fhandler_termios.cc (tty_min::kill_pgrp): Use _pinfo::exists rather + than proc_exists. + * pinfo.cc (pinfo::init): Ditto. Don't do a low_priority_sleep(0) when + looping to find exec'ed procinfo. + (pinfo::release): Be more careful about unmapping and closing. + * signal.cc (_pinfo::kill): Rename from kill_worker. Accommodate entry + into _pinfo class. + (kill0): Use _pinfo::kill rather than kill_worker. + (kill_pgrp): Ditto. Use _pinfo::exists rather than proc_exists. + * sigproc.cc (_pinfo::exists): Rename from proc_exists. + (pid_exists): Use _pinfo::exists rather than proc_exists. + (remove_proc): Ditto. + * sigproc.h (proc_exists): Delete declaration. + 2005-02-25 Corinna Vinschen <corinna@vinschen.de> * fhandler.h (class fhandler_base): Declare fixup_mmap_after_fork @@ -145,7 +165,7 @@ (fhandler_base::fstat_by_name): Pass pc.volser () to fstat_helper. Accomodate dropping default values for last three arguments of fstat_helper. - (fhandler_base::fstat_helper): Add dwVolumeSerialNumber argument. + (fhandler_base::fstat_helper): Add dwVolumeSerialNumber argument. Use for st_dev member unless 0 in which case pc.volser () is used. 2005-02-20 Corinna Vinschen <corinna@vinschen.de> diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc index 7411a5d40..075830f97 100644 --- a/winsup/cygwin/debug.cc +++ b/winsup/cygwin/debug.cc @@ -162,7 +162,7 @@ static void __stdcall delete_handle (handle_list *hl) { handle_list *hnuke = hl->next; - debug_printf ("nuking handle '%s'", hnuke->name); + debug_printf ("nuking handle '%s' (%p)", hnuke->name, hnuke->h); hl->next = hl->next->next; memset (hnuke, 0, sizeof (*hnuke)); } diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index ecef3b8a9..d1d65dd22 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -94,7 +94,7 @@ tty_min::kill_pgrp (int sig) for (unsigned i = 0; i < pids.npids; i++) { _pinfo *p = pids[i]; - if (!proc_exists (p) || p->ctty != ntty || p->pgid != pgid) + if (!p->exists () || p->ctty != ntty || p->pgid != pgid) continue; if (p == myself) killself++; diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index ce59d2245..671c3c4e3 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -181,7 +181,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE h0) } void *mapaddr; - bool createit = !!(flag & (PID_IN_USE | PID_EXECED)); + int createit = flag & (PID_IN_USE | PID_EXECED); bool created = false; DWORD access = FILE_MAP_READ | (flag & (PID_IN_USE | PID_EXECED | PID_MAP_RW) @@ -257,7 +257,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE h0) if (procinfo->process_state & PID_EXECED) { - assert (!i); + assert (i == 0); pid_t realpid = procinfo->pid; debug_printf ("execed process windows pid %d, cygwin pid %d", n, realpid); if (realpid == n) @@ -296,7 +296,8 @@ pinfo::init (pid_t n, DWORD flag, HANDLE h0) loop: release (); - low_priority_sleep (0); + if (h0) + low_priority_sleep (0); } if (h) @@ -338,7 +339,7 @@ _pinfo::set_ctty (tty_min *tc, int flags, fhandler_tty_slave *arch) tc->ntty, sid, pid, pgid, tc->getsid ()); pinfo p (tc->getsid ()); - if (sid == pid && (!p || p->pid == pid || !proc_exists (p))) + if (sid == pid && (!p || p->pid == pid || !p->exists ())) { paranoid_printf ("resetting tty%d sid. Was %d, now %d. pgid was %d, now %d.", tc->ntty, tc->getsid (), sid, tc->getpgid (), pgid); @@ -1132,17 +1133,15 @@ pinfo::release () { if (procinfo) { -#ifdef DEBUGGING - if (((DWORD) procinfo & 0x77000000) == 0x61000000) - try_to_debug (); -#endif - UnmapViewOfFile (procinfo); + void *unmap_procinfo = procinfo; procinfo = NULL; + UnmapViewOfFile (unmap_procinfo); } if (h) { - ForceCloseHandle1 (h, pinfo_shared_handle); + HANDLE close_h = h; h = NULL; + ForceCloseHandle1 (close_h, pinfo_shared_handle); } } diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index 586a6cc7f..877c22235 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -123,6 +123,8 @@ public: bool dup_proc_pipe (HANDLE) __attribute__ ((regparm(2))); void sync_proc_pipe (); bool alert_parent (char); + int __stdcall kill (siginfo_t&) __attribute__ ((regparm (2))); + bool __stdcall exists () __attribute__ ((regparm (1))); friend void __stdcall set_myself (HANDLE); diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 8cb26be50..81cc2e7ee 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -182,16 +182,15 @@ handle_sigprocmask (int sig, const sigset_t *set, sigset_t *oldset, sigset_t& op return 0; } -static int -kill_worker (pid_t pid, siginfo_t& si) +int __stdcall +_pinfo::kill (siginfo_t& si) { sig_dispatch_pending (); int res = 0; - pinfo dest (pid); bool sendSIGCONT; - if (!dest) + if (!exists ()) { set_errno (ESRCH); return -1; @@ -200,14 +199,10 @@ kill_worker (pid_t pid, siginfo_t& si) if ((sendSIGCONT = (si.si_signo < 0))) si.si_signo = -si.si_signo; - DWORD process_state = dest->process_state; + DWORD this_process_state = process_state; if (si.si_signo == 0) - { - res = proc_exists (dest) ? 0 : -1; - if (res < 0) - set_errno (ESRCH); - } - else if ((res = sig_send (dest, si))) + /* ok */; + else if ((res = sig_send (this, si))) { sigproc_printf ("%d = sig_send, %E ", res); res = -1; @@ -218,11 +213,11 @@ kill_worker (pid_t pid, siginfo_t& si) si2.si_signo = SIGCONT; si2.si_code = SI_KERNEL; si2.si_pid = si2.si_uid = si2.si_errno = 0; - (void) sig_send (dest, si2); + (void) sig_send (this, si2); } - syscall_printf ("%d = kill_worker (%d, %d), process_state %p", res, pid, - si.si_signo, process_state); + syscall_printf ("%d = _pinfo::kill (%d, %d), process_state %p", res, pid, + si.si_signo, this_process_state); return res; } @@ -250,7 +245,7 @@ kill0 (pid_t pid, siginfo_t& si) (si.si_signo == SIGTSTP || si.si_signo == SIGTTIN || si.si_signo == SIGTTOU)) si.si_signo = 0; - return (pid > 0) ? kill_worker (pid, si) : kill_pgrp (-pid, si); + return (pid > 0) ? pinfo (pid)->kill (si) : kill_pgrp (-pid, si); } int @@ -286,7 +281,7 @@ kill_pgrp (pid_t pid, siginfo_t& si) { _pinfo *p = pids[i]; - if (!proc_exists (p)) + if (!p->exists ()) continue; /* Is it a process we want to kill? */ @@ -298,12 +293,12 @@ kill_pgrp (pid_t pid, siginfo_t& si) p->pid, p->pgid, p->ctty, myself->ctty); if (p == myself) killself++; - else if (kill_worker (p->pid, si)) + else if (p->kill (si)) res = -1; found++; } - if (killself && !exit_state && kill_worker (myself->pid, si)) + if (killself && !exit_state && myself->kill (si)) res = -1; if (!found) diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index c6fa2637b..66e7395ab 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -192,16 +192,15 @@ proc_can_be_signalled (_pinfo *p) bool __stdcall pid_exists (pid_t pid) { - pinfo p (pid); - return proc_exists (p); + return pinfo (pid)->exists (); } /* Test to determine if a process really exists and is processing signals. */ bool __stdcall -proc_exists (_pinfo *p) +_pinfo::exists () { - return p && !(p->process_state & PID_EXITED); + return this && !(process_state & PID_EXITED); } /* Return true if this is one of our children, false otherwise. */ @@ -847,7 +846,7 @@ out: static bool __stdcall remove_proc (int ci) { - if (proc_exists (procs[ci])) + if (procs[ci]->exists ()) return true; sigproc_printf ("removing procs[%d], pid %d, nprocs %d", ci, procs[ci]->pid, diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index b53e250d0..a4e8a7147 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -73,7 +73,6 @@ class _pinfo; void __stdcall proc_terminate (); void __stdcall sigproc_init (); void __stdcall sigproc_terminate (); -bool __stdcall proc_exists (_pinfo *) __attribute__ ((regparm(1))); bool __stdcall pid_exists (pid_t) __attribute__ ((regparm(1))); int __stdcall sig_send (_pinfo *, siginfo_t&, class _cygtls *tls = NULL) __attribute__ ((regparm (3))); int __stdcall sig_send (_pinfo *, int) __attribute__ ((regparm (2))); |