File 3841-JOB_OBJECT_LIMIT_BREAKAWAY_OK.patch of Package erlang
From fad4f79cb8821464855e71e864984651cee3ef56 Mon Sep 17 00:00:00 2001
From: obi458 <oliver.bollmann@t-online.de>
Date: Tue, 12 Oct 2021 22:33:45 +0200
Subject: [PATCH] JOB_OBJECT_LIMIT_BREAKAWAY_OK
---
erts/etc/win32/erlsrv/erlsrv_service.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/erts/etc/win32/erlsrv/erlsrv_service.c b/erts/etc/win32/erlsrv/erlsrv_service.c
index 47b9c72690..ed4f6e2171 100644
--- a/erts/etc/win32/erlsrv/erlsrv_service.c
+++ b/erts/etc/win32/erlsrv/erlsrv_service.c
@@ -535,10 +535,14 @@ static BOOL start_a_service(ServerInfo *srvi){
HANDLE hJob = CreateJobObject(NULL, NULL);
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
/*
- * Causes all processes associated with the job to terminate when the
- * last handle to the job is closed.
- */
- jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
+ * JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
+ * Causes all processes associated with the job to terminate when the
+ * last handle to the job is closed.
+ *
+ * JOB_OBJECT_LIMIT_BREAKAWAY_OK
+ * Sometimes we want to break out, for example to start programs in another windows session
+ */
+ jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK;
SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli));
if (AssignProcessToJobObject(hJob, GetCurrentProcess()) == FALSE) {
log_error(L"Could not AssignProcessToJobObject");
--
2.34.1