aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2019-04-02 13:00:22 +0200
committerCorinna Vinschen <corinna@vinschen.de>2019-04-02 13:00:44 +0200
commitb9009a58802ffe0c1419bc5f517cfb5e09b7c80b (patch)
treebc1abf0f392514b47319fe267de28ddd5c570d7a
parent4fb8d091f2937284d7be09b69c68e0e755a175f6 (diff)
downloadnewlib-b9009a58802ffe0c1419bc5f517cfb5e09b7c80b.zip
newlib-b9009a58802ffe0c1419bc5f517cfb5e09b7c80b.tar.gz
newlib-b9009a58802ffe0c1419bc5f517cfb5e09b7c80b.tar.bz2
Cygwin: winpids: Fix getting process multiple times, take 2
commit d1be0a59d48222d8ea6261ee3e59de2bc3d149e4, "Cygwin: winpids: Fix getting process multiple times" fixed duplicate processes in ps -W output, but it fixed the symptom, not the cause. It also didn't fix the problem that the `ps' process itself may show up twice in its own output. This patch fixes it. The spawn worker only deleted the "winpid.PID" symlink of the current process if the child is a non-Cygwin process, under the assumption that the exec'ing process exits anyway. However, the Window in which both winpid.PID symlinks point to the same cygpid.PID area is just too long. The spawn worker now also deletes its own winpid.PID symlink if the exec'ed process is a Cygwin process. Additionally the fix from d1be0a59d48222d8ea6261ee3e59de2bc3d149e4 is now performed on the calling process, too. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/pinfo.cc6
-rw-r--r--winsup/cygwin/release/3.0.614
-rw-r--r--winsup/cygwin/spawn.cc9
3 files changed, 21 insertions, 8 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index bead85b..d002268 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -1443,10 +1443,10 @@ winpids::add (DWORD& nelem, bool winpid, DWORD pid)
perform_copy = onreturn ? make_copy : true;
p.init (cygpid, PID_PROCINFO | pinfo_access, NULL);
- /* Did we catch the process during exec? Try to fix. */
- if (p && p->dwProcessId != pid)
- pid = p->dwProcessId;
}
+ /* Did we catch the process during exec? Try to fix. */
+ if (p && p->dwProcessId != pid)
+ pid = p->dwProcessId;
/* If we're just looking for winpids then don't do any special cygwin "stuff* */
if (winpid)
diff --git a/winsup/cygwin/release/3.0.6 b/winsup/cygwin/release/3.0.6
new file mode 100644
index 0000000..14a8329
--- /dev/null
+++ b/winsup/cygwin/release/3.0.6
@@ -0,0 +1,14 @@
+What's new:
+-----------
+
+
+What changed:
+-------------
+
+
+Bug Fixes
+---------
+
+- Fix the problem that `ps' or `pstree' may show up in their own
+ output twice.
+ Addresses: Report on IRC
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 4e549f7..579b3c9 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -727,16 +727,15 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
myself->dwProcessId = pi.dwProcessId;
strace.execing = 1;
myself.hProcess = hExeced = pi.hProcess;
+ HANDLE old_winpid_hdl = myself.shared_winpid_handle ();
if (!real_path.iscygexec ())
{
/* If the child process is not a Cygwin process, we have to
- create a new winpid symlink and drop the old one on
- behalf of the child process not being able to do this
- by itself. */
- HANDLE old_winpid_hdl = myself.shared_winpid_handle ();
+ create a new winpid symlink on behalf of the child process
+ not being able to do this by itself. */
myself.create_winpid_symlink ();
- NtClose (old_winpid_hdl);
}
+ NtClose (old_winpid_hdl);
real_path.get_wide_win32_path (myself->progname); // FIXME: race?
sigproc_printf ("new process name %W", myself->progname);
if (!iscygwin ())