CreateProcessW with JOB_LIST: guaranteed outcome if creator dies before PROCESS_INFORMATION is returned?

ThanhTrung 0 Reputation points
2026-11-21T00:13:23.83+00:00

Environment: Windows Server 2025 x64 (AMD64), Win32 desktop APIs.

I am looking for clarification of the supported Windows API contract when a process creating another process terminates unexpectedly inside CreateProcessW, before receiving a return value or usable PROCESS_INFORMATION.

This is a hypothetical lifecycle-safety question, not a report of an observed Windows bug or orphaned process.

Scenario and assumptions

An independent, long-lived supervisor S owns a fresh Job Object J.

  • S configures JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, does not enable BREAKAWAY_OK or SILENT_BREAKAWAY_OK, and retains a valid, noninheritable controlling handle.

If an outer Job exists, assume a supported nested-Job configuration.

A separate creator process W has a valid Job handle with appropriate rights.

W uses STARTUPINFOEXW, EXTENDED_STARTUPINFO_PRESENT, and UpdateProcThreadAttribute(PROC_THREAD_ATTRIBUTE_JOB_LIST) to request creation-time association with J.

Assume valid structures, handle lifetimes, and properly configured attributes.

The core scenario concerns ordinary CreateProcessW. Relevant variants include DEBUG_ONLY_THIS_PROCESS and CREATE_SUSPENDED, but neither flag should be assumed to prove Job membership or cleanup.

Critical interruption:

W enters CreateProcessW.

Windows may have partially completed internal process creation.

W terminates unexpectedly before the API returns.

No usable target process handle, PID, or PROCESS_INFORMATION has been published to S.

S remains alive, retains J, and attempts fail-stop cleanup.

Assume only one in-flight creation attempt and no new launches during shutdown.

This is distinct from CreateProcessW returning FALSE, because in this case no API return was observed.

Q1. Intermediate process-creation states

What target states are possible under the documented Windows contract if W terminates inside CreateProcessW?

Can a process object or suspended target survive without successful PROCESS_INFORMATION publication?

Is an unmanaged surviving target excluded by a documented guarantee, or does this outcome remain unspecified?

Q2. Creation-time Job membership

With PROC_THREAD_ATTRIBUTE_JOB_LIST configured correctly, is every potentially surviving child guaranteed to have completed Job association before its initial thread can execute?

Does this guarantee apply when the creator terminates during CreateProcessW?

Does initial-thread ordering also exclude an unassigned, suspended, partially created target?

Q3. Termination during in-flight creation

Suppose S calls TerminateJobObject(J) while W's CreateProcessW is incomplete.

Can an in-flight target subsequently complete Job admission or survive outside the demonstrated control of S?

Is there a documented synchronization or ordering guarantee between in-flight process creation, Job assignment, and Job termination?

Please distinguish a termination request from observed process exit.

Q4. Reliable terminal observation

If S never received the target's process handle or PID, how can it establish a trustworthy final outcome?

Does waiting for W's process handle to become signaled and observing ActiveProcesses == 0 provide a supported barrier against later admission of an in-flight target?

If not, what supported observation or synchronization mechanism should be used?

How should incomplete process lists, completion-port limitations, and PID reuse be handled?

Q5. Supported architecture and limitations

What supported Windows-native architecture provides lifecycle ownership under this exact creator-loss scenario?

Would either of the following resolve the concern?

Moving CreateProcessW into a long-lived supervisor.

Placing W inside J before execution and relying on documented Job inheritance for its child.

If the creator or debugger thread terminates during creation, what cleanup and observation guarantees apply?

Also, if a creating supervisor is the sole user-mode holder of the Job handle, how do last-handle closure and any internal references during creation affect the outcome?

If there is no supported guarantee using these APIs, an explicit statement of that limitation would be helpful.

Requested clarification

Please identify the applicable Windows versions/builds, API preconditions, Job access rights, flags, nesting/breakaway requirements, and relevant limitations.

In particular, I am looking to distinguish:

Documented Win32 API guarantees.

Authoritative Windows engineering clarification.

Recommended implementation practices.

Behavior that remains unspecified or requires experimental investigation.

A successful test run alone would not establish a guarantee for every interruption timing.

Relevant Microsoft documentation

CreateProcessW

UpdateProcThreadAttribute

Job Objects

TerminateJobObject

QueryInformationJobObject

Raymond Chen: Job assignment at process creation

I understand that creation-time Job assignment occurs before initial-thread execution, but I have not found an explicit contract covering the entire interrupted-creation and terminal-observation scenario.

Thank you for any documentation references or engineering clarification.Environment: Windows Server 2025 x64 (AMD64), Win32 desktop APIs.

I am looking for clarification of the supported Windows API contract when a process creating another process terminates unexpectedly inside CreateProcessW, before receiving a return value or usable PROCESS_INFORMATION.

This is a hypothetical lifecycle-safety question, not a report of an observed Windows bug or orphaned process.

Scenario and assumptions

An independent, long-lived supervisor S owns a fresh Job Object J.

S configures JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, does not enable BREAKAWAY_OK or SILENT_BREAKAWAY_OK, and retains a valid, noninheritable controlling handle.

If an outer Job exists, assume a supported nested-Job configuration.

A separate creator process W has a valid Job handle with appropriate rights.

W uses STARTUPINFOEXW, EXTENDED_STARTUPINFO_PRESENT, and UpdateProcThreadAttribute(PROC_THREAD_ATTRIBUTE_JOB_LIST) to request creation-time association with J.

Assume valid structures, handle lifetimes, and properly configured attributes.

The core scenario concerns ordinary CreateProcessW. Relevant variants include DEBUG_ONLY_THIS_PROCESS and CREATE_SUSPENDED, but neither flag should be assumed to prove Job membership or cleanup.

Critical interruption:

W enters CreateProcessW.

Windows may have partially completed internal process creation.

W terminates unexpectedly before the API returns.

No usable target process handle, PID, or PROCESS_INFORMATION has been published to S.

S remains alive, retains J, and attempts fail-stop cleanup.

Assume only one in-flight creation attempt and no new launches during shutdown.

This is distinct from CreateProcessW returning FALSE, because in this case no API return was observed.

Q1. Intermediate process-creation states

What target states are possible under the documented Windows contract if W terminates inside CreateProcessW?

Can a process object or suspended target survive without successful PROCESS_INFORMATION publication?

Is an unmanaged surviving target excluded by a documented guarantee, or does this outcome remain unspecified?

Q2. Creation-time Job membership

With PROC_THREAD_ATTRIBUTE_JOB_LIST configured correctly, is every potentially surviving child guaranteed to have completed Job association before its initial thread can execute?

Does this guarantee apply when the creator terminates during CreateProcessW?

Does initial-thread ordering also exclude an unassigned, suspended, partially created target?

Q3. Termination during in-flight creation

Suppose S calls TerminateJobObject(J) while W's CreateProcessW is incomplete.

Can an in-flight target subsequently complete Job admission or survive outside the demonstrated control of S?

Is there a documented synchronization or ordering guarantee between in-flight process creation, Job assignment, and Job termination?

Please distinguish a termination request from observed process exit.

Q4. Reliable terminal observation

If S never received the target's process handle or PID, how can it establish a trustworthy final outcome?

Does waiting for W's process handle to become signaled and observing ActiveProcesses == 0 provide a supported barrier against later admission of an in-flight target?

If not, what supported observation or synchronization mechanism should be used?

How should incomplete process lists, completion-port limitations, and PID reuse be handled?

Q5. Supported architecture and limitations

What supported Windows-native architecture provides lifecycle ownership under this exact creator-loss scenario?

Would either of the following resolve the concern?

Moving CreateProcessW into a long-lived supervisor.

Placing W inside J before execution and relying on documented Job inheritance for its child.

If the creator or debugger thread terminates during creation, what cleanup and observation guarantees apply?

Also, if a creating supervisor is the sole user-mode holder of the Job handle, how do last-handle closure and any internal references during creation affect the outcome?

If there is no supported guarantee using these APIs, an explicit statement of that limitation would be helpful.

Requested clarification

Please identify the applicable Windows versions/builds, API preconditions, Job access rights, flags, nesting/breakaway requirements, and relevant limitations.

In particular, I am looking to distinguish:

Documented Win32 API guarantees.

Authoritative Windows engineering clarification.

Recommended implementation practices.

Behavior that remains unspecified or requires experimental investigation.

A successful test run alone would not establish a guarantee for every interruption timing.

Relevant Microsoft documentation

CreateProcessW

UpdateProcThreadAttribute

Job Objects

TerminateJobObject

QueryInformationJobObject

Raymond Chen: Job assignment at process creation

I understand that creation-time Job assignment occurs before initial-thread execution, but I have not found an explicit contract covering the entire interrupted-creation and terminal-observation scenario.

Thank you for any documentation references or engineering clarification.

Windows development | Windows API - Win32
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.