{"record":{"id":"60cab00029883a24","repo":"microsoft/aspire","slug":"failed-to-configure-cli-kill-on-parent-exit-job-object","errorCode":null,"errorMessage":"Failed to configure CLI kill-on-parent-exit job object limits","messagePattern":"Failed to configure CLI kill-on-parent-exit job object limits","errorType":"exception","errorClass":"Win32Exception","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Processes/WindowsConsoleProcessJob.cs","lineNumber":97,"sourceCode":"                {\n                    LimitFlags = WindowsProcessInterop.JobObjectLimitKillOnJobClose\n                                 | WindowsProcessInterop.JobObjectLimitBreakawayOk,\n                },\n            };\n\n            var infoSize = Marshal.SizeOf<WindowsProcessInterop.JOBOBJECT_EXTENDED_LIMIT_INFORMATION>();\n            var infoPtr = Marshal.AllocHGlobal(infoSize);\n            try\n            {\n                Marshal.StructureToPtr(info, infoPtr, fDeleteOld: false);\n\n                if (!WindowsProcessInterop.SetInformationJobObject(\n                    _jobHandle,\n                    WindowsProcessInterop.JobObjectInfoClass.ExtendedLimitInformation,\n                    infoPtr,\n                    (uint)infoSize))\n                {\n                    throw new Win32Exception(Marshal.GetLastWin32Error(), \"Failed to configure CLI kill-on-parent-exit job object limits\");\n                }\n            }\n            finally\n            {\n                Marshal.FreeHGlobal(infoPtr);\n            }\n        }\n        catch\n        {\n            // Constructor failure must not leave the partial job alive; closing the handle\n            // would also fire KILL_ON_JOB_CLOSE harmlessly (zero processes assigned yet) but\n            // mainly we just don't want to leak a kernel object.\n            _jobHandle.Dispose();\n            throw;\n        }\n    }\n\n    /// <summary>","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Processes/WindowsConsoleProcessJob.cs#L79-L115","documentation":"The Aspire CLI creates a Windows Job Object (WindowsConsoleProcessJob) with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE so child processes die when the CLI exits. This error is thrown when the native SetInformationJobObject call that applies those limits (KILL_ON_JOB_CLOSE + BREAKAWAY_OK) returns false. It wraps the last Win32 error, so the inner message names the underlying OS failure code.","triggerScenarios":"Constructing WindowsConsoleProcessJob (e.g. via WindowsConsoleProcessJob.Shared on first access when a process is started with killOnParentExit: true) on Windows where SetInformationJobObject(JobObjectExtendedLimitInformation) fails for the freshly created job handle.","commonSituations":"Corrupted or hardened OS images restricting Job Object APIs; security/EDR software blocking job-object manipulation; running in restricted job sandboxes (CI containers, some CI runners nest processes in jobs with JOB_OBJECT_LIMIT_SILENT_BREAKAWAY restrictions); extremely rare kernel/memory pressure causing marshalling or native-call failure.","solutions":["Read the inner Win32Exception to identify the native error code (e.g. ERROR_ACCESS_DENIED) and check whether antivirus/EDR or a CI sandbox is blocking Job Object APIs.","If running inside a CI/agent job that already places the process in a restrictive job, run the CLI outside that job or add breakaway permissions.","Retry after a reboot/update of Windows; a corrupted kernel state is rare but possible.","As a last resort run the CLI with killOnParentExit disabled (accepting orphaned child processes) if the code path allows it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    var job = WindowsConsoleProcessJob.Shared;\n}\ncatch (Win32Exception ex)\n{\n    logger.LogError(ex, \"Job object limits could not be set (Win32 error {Code}). Falling back to watchdog-only cleanup.\", ex.ErrorCode);\n}","preventionTips":["Run the CLI outside restrictive CI job sandboxes where possible.","Keep antivirus/EDR exclusions for developer CLI tooling.","Log and surface the inner Win32 error code for diagnosis."],"tags":["windows","win32","job-object","process-management","cli"],"backgroundTag":"win32-api-call-failed","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}