From deb648cc8b95ec4b7a5b604d958abd338347811f Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 17 Sep 2003 01:15:56 +0000 Subject: * pinfo.h (winpids::pid_access): New element. (winpids::winpids): Rejigger to set pinfo_access. * pinfo.cc (winpids::add): Try to open shared memory region with supplied pinfo_access first, then default to readonly. * fhandler_termios.cc (tty_min::kill_pgrp): When getting list of pids to work with, suggest opening with PID_MAP_RW. * signal.cc (kill_pgrp): Ditto. * sigproc.cc (sig_send): Perform a write check on todo prior to attempting to increment it. Return EACCES if we can't write to it. --- winsup/cygwin/pinfo.cc | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'winsup/cygwin/pinfo.cc') diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index eabf6a92c..6c59860c6 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -541,22 +541,31 @@ winpids::add (DWORD& nelem, bool winpid, DWORD pid) pinfolist = (pinfo *) realloc (pinfolist, size_pinfolist (npidlist + 1)); } - pinfolist[nelem].init (cygpid, PID_NOREDIR | (winpid ? PID_ALLPIDS : 0)); + pinfolist[nelem].init (cygpid, PID_NOREDIR | (winpid ? PID_ALLPIDS : 0) + | pinfo_access); if (winpid) - /* nothing to do */; - else if (!pinfolist[nelem]) - return; - else - /* Scan list of previously recorded pids to make sure that this pid hasn't - shown up before. This can happen when a process execs. */ - for (unsigned i = 0; i < nelem; i++) - if (pinfolist[i]->pid == pinfolist[nelem]->pid) - { - if ((_pinfo *) pinfolist[nelem] != (_pinfo *) myself) - pinfolist[nelem].release (); - return; - } + goto out; + if (!pinfolist[nelem]) + { + if (!pinfo_access) + return; + pinfolist[nelem].init (cygpid, PID_NOREDIR | (winpid ? PID_ALLPIDS : 0)); + if (!pinfolist[nelem]) + return; + } + + /* Scan list of previously recorded pids to make sure that this pid hasn't + shown up before. This can happen when a process execs. */ + for (unsigned i = 0; i < nelem; i++) + if (pinfolist[i]->pid == pinfolist[nelem]->pid) + { + if ((_pinfo *) pinfolist[nelem] != (_pinfo *) myself) + pinfolist[nelem].release (); + return; + } + +out: pidlist[nelem++] = pid; } -- cgit v1.2.3