From 276448cf67102d31ccd1c5b4186ac84aeeabf9d2 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 13 Sep 2003 17:14:15 +0000 Subject: [PATCH] * include/sys/cygwin.h: Rename PID_UNUSED to PID_MAP_RW. * pinfo.cc (pinfo_init): Initialize myself->gid. (pinfo::init): Create the "access" variable, set it appropriately and use it to specify the requested access. * exceptions.cc (sig_handle_tty_stop): Add PID_MAP_RW in pinfo parent. * signal.cc (kill_worker): Ditto for pinfo dest. * syscalls.cc (setpgid): Ditto for pinfo p. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/exceptions.cc | 2 +- winsup/cygwin/include/sys/cygwin.h | 2 +- winsup/cygwin/pinfo.cc | 9 +++++---- winsup/cygwin/signal.cc | 2 +- winsup/cygwin/syscalls.cc | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 55173f3d5..cef75e0a8 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2003-09-13 Pierre Humblet + + * include/sys/cygwin.h: Rename PID_UNUSED to PID_MAP_RW. + * pinfo.cc (pinfo_init): Initialize myself->gid. + (pinfo::init): Create the "access" variable, set it appropriately and + use it to specify the requested access. + * exceptions.cc (sig_handle_tty_stop): Add PID_MAP_RW in pinfo parent. + * signal.cc (kill_worker): Ditto for pinfo dest. + * syscalls.cc (setpgid): Ditto for pinfo p. + 2003-09-13 Christopher Faylor * include/cygwin/version.h: Bump DLL minor number to 5. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index c1743d239..4206e38de 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -614,7 +614,7 @@ sig_handle_tty_stop (int sig) its list of subprocesses. */ if (my_parent_is_alive ()) { - pinfo parent (myself->ppid); + pinfo parent (myself->ppid, PID_MAP_RW); if (NOTSTATE (parent, PID_NOCLDSTOP)) sig_send (parent, SIGCHLD); } diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index 9dd46db16..36c3f53b1 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -89,7 +89,7 @@ enum PID_ORPHANED = 0x0020, /* Member of an orphaned process group. */ PID_ACTIVE = 0x0040, /* Pid accepts signals. */ PID_CYGPARENT = 0x0080, /* Set if parent was a cygwin app. */ - PID_UNUSED = 0x0100, /* ... */ + PID_MAP_RW = 0x0100, /* Flag to open map rw. */ PID_MYSELF = 0x0200, /* Flag that pid is me. */ PID_NOCLDSTOP = 0x0400, /* Set if no SIGCHLD signal on stop. */ PID_INITIALIZING = 0x0800, /* Set until ready to receive signals. */ diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 3d11b24d5..aca4dff4d 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -89,7 +89,7 @@ pinfo_init (char **envp, int envc) myself->pgid = myself->sid = myself->pid; myself->ctty = -1; myself->uid = ILLEGAL_UID; - + myself->gid = UNKNOWN_GID; environ_init (NULL, 0); /* call after myself has been set up */ } @@ -138,6 +138,8 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h) } int createit = flag & (PID_IN_USE | PID_EXECED); + DWORD access = FILE_MAP_READ + | (flag & (PID_IN_USE | PID_EXECED | PID_MAP_RW) ? FILE_MAP_WRITE : 0); for (int i = 0; i < 10; i++) { int created; @@ -157,7 +159,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h) } else if (!createit) { - h = OpenFileMappingA (FILE_MAP_READ | FILE_MAP_WRITE, FALSE, mapname); + h = OpenFileMappingA (access, FALSE, mapname); created = 0; } else @@ -175,8 +177,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h) return; } - procinfo = (_pinfo *) MapViewOfFileEx (h, FILE_MAP_READ | FILE_MAP_WRITE, - 0, 0, 0, mapaddr); + procinfo = (_pinfo *) MapViewOfFileEx (h, access, 0, 0, 0, mapaddr); ProtectHandle1 (h, pinfo_shared_handle); if ((procinfo->process_state & PID_INITIALIZING) && (flag & PID_NOREDIR) diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 133f192b4..5ee4cc71a 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -173,7 +173,7 @@ kill_worker (pid_t pid, int sig) sig_dispatch_pending (); int res = 0; - pinfo dest (pid); + pinfo dest (pid, PID_MAP_RW); BOOL sendSIGCONT; if (!dest) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index a6a2b1bc7..041482346 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1961,7 +1961,7 @@ setpgid (pid_t pid, pid_t pgid) } else { - pinfo p (pid); + pinfo p (pid, PID_MAP_RW); if (!p) { set_errno (ESRCH);