Eric Pouech : start: Wrap child inside a job so it gets killed when start.exe terminates.

Alexandre Julliard julliard at winehq.org
Tue Jan 25 15:41:20 CST 2022


Module: wine
Branch: master
Commit: a1abb524fee5b033e761d700b87353f14b009680
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a1abb524fee5b033e761d700b87353f14b009680

Author: Eric Pouech <eric.pouech at gmail.com>
Date:   Tue Jan 25 08:31:34 2022 +0100

start: Wrap child inside a job so it gets killed when start.exe terminates.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50869
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/start/start.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/programs/start/start.c b/programs/start/start.c
index dcd0a113f59..b5bf8187603 100644
--- a/programs/start/start.c
+++ b/programs/start/start.c
@@ -676,7 +676,24 @@ done:
 
 	if (sei.fMask & SEE_MASK_NOCLOSEPROCESS) {
 		DWORD exitcode;
+		HANDLE hJob;
+		JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
+
 		SetConsoleCtrlHandler(NULL, TRUE);
+		hJob = CreateJobObjectA(NULL, NULL);
+		/* Create a job where the child is associated... if the start.exe terminates
+		 * before the child, the job will be terminated, and the child will be terminated as well.
+		 * (The idea is to allow to kill (from a Unix standpoint) a created Windows
+		 * process (here start.exe), and that the unix-kill of start.exe will be also terminate
+		 * start.exe's child process).
+		 */
+		memset(&info, 0, sizeof(info));
+		info.BasicLimitInformation.LimitFlags =
+                    JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE |
+                    JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK;
+		SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &info, sizeof(info));
+		AssignProcessToJobObject(hJob, sei.hProcess);
+
 		WaitForSingleObject(sei.hProcess, INFINITE);
 		GetExitCodeProcess(sei.hProcess, &exitcode);
 		ExitProcess(exitcode);




More information about the wine-cvs mailing list