pinfo::thisproc (HANDLE h)
{
procinfo = NULL;
+ bool execed = !!h;
DWORD flags = PID_IN_USE | PID_ACTIVE;
/* Forked process or process started from non-Cygwin parent needs a pid. */
- if (!h)
+ if (!execed)
{
cygheap->pid = create_cygwin_pid ();
flags |= PID_NEW;
procinfo->dwProcessId = myself_initial.dwProcessId;
procinfo->sendsig = myself_initial.sendsig;
wcscpy (procinfo->progname, myself_initial.progname);
- create_winpid_symlink ();
+ if (!execed)
+ create_winpid_symlink ();
procinfo->exec_sendsig = NULL;
procinfo->exec_dwProcessId = 0;
debug_printf ("myself dwProcessId %u", procinfo->dwProcessId);
- Fix an issue that command "cmd /c script -c cmd" crashes if it
is issued in console of Windows 7.
+
+- Fix killpg failing because the exec'ing as well as the exec'ed
+ process are not in the pidlist for a brief moment.
+ Addresses: https://cygwin.com/pipermail/cygwin/2022-May/251479.html
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 on behalf of the child process
- not being able to do this by itself. */
- myself.create_winpid_symlink ();
- }
+ /* We have to create a new winpid symlink on behalf of the child
+ process. For Cygwin processes we also have to create a reference
+ in the child. */
+ myself.create_winpid_symlink ();
+ if (real_path.iscygexec ())
+ DuplicateHandle (GetCurrentProcess (),
+ myself.shared_winpid_handle (),
+ pi.hProcess, NULL, 0, 0, DUPLICATE_SAME_ACCESS);
NtClose (old_winpid_hdl);
real_path.get_wide_win32_path (myself->progname); // FIXME: race?
sigproc_printf ("new process name %W", myself->progname);