There is no publicly documented Windows API admission-completion barrier that lets an independent guardian prove that every in-progress CreateProcessW operation referencing a Job Object has completed or been cancelled.
PROC_THREAD_ATTRIBUTE_JOB_LIST closes the execution-before-assignment race, but the published contract does not make the Job Object an admission queue, expose pending admissions, or define a drain/close operation for them. It assigns the child to the listed jobs in order and is supported on Windows 10/Windows Server 2016 and later.^1^ Assignment occurs before the initial thread runs.^2^
Documented guarantees—and the gaps
- Interrupted
CreateProcessWThe documented API result is available only when the call returns: nonzero withPROCESS_INFORMATION, or zero withGetLastError. It also states that a successful return precedes completion of process initialization.^3^ The public contract does not specify what a different process may infer if the caller or calling thread disappears, remains blocked, or never reports that result. In particular, it does not document:- cancellation caused by caller termination;
- rollback of all process-creation state;
- a recoverable transaction identifier;
- a waitable object representing the outstanding creation;
- a maximum time by which admission must become visible.
- Multiple jobs and partial assignment The documented behavior is sequential assignment in the supplied order, and the order must form a valid job hierarchy.^1^ Nested-job rules explain which hierarchy orders are valid and that invalid explicit assignments fail.^4^ The cited public contract does not define atomic all-or-nothing rollback for
PROC_THREAD_ATTRIBUTE_JOB_LIST, nor does it document that a process can permanently survive with only a prefix of the requested jobs after creation fails. Either conclusion would exceed the published guarantee. The pre-initial-thread guarantee does establish that the child cannot execute user code between these creation-time assignments. - Accounting and process-ID queries
ActiveProcessesis current job accounting, not a count of pendingCreateProcessWoperations.^5^ Likewise,JobObjectBasicProcessIdListreports processes associated with the job and, for nested jobs, its child jobs; it does not report pending admissions.^6^ - Completion-port notifications
JOB_OBJECT_MSG_ACTIVE_PROCESS_ZEROmeans the active count was decremented to zero. It is not documented as an admission fence. Ordinary job messages—including new-process, exit-process, and active-process-zero notifications—are notifications whose delivery is generally not guaranteed, and Microsoft explicitly warns about races involving new/exit messages.^7^ Therefore, neither receipt ofACTIVE_PROCESS_ZEROnor the absence of a subsequentNEW_PROCESSnotification proves admission closure. -
TerminateJobObjectThis terminates processes currently associated with the job and, for a nested job, processes currently associated with its child jobs.^8^ It is not documented as:- preventing future assignment;
- waiting for pending creation operations;
- cancelling operations holding job handles;
- permanently placing the job into an admission-closed state.
TerminateJobObjectinto a general drain barrier for already-started creation-time assignments.^9^ - Kill-on-close
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSEterminates processes associated with the job when its last handle closes.^10^ The public documentation does not define ordering between final external-handle closure and undocumented internal references held during process creation. It therefore cannot be used as proof that a pending admission has drained. - Nested jobs Nested jobs are supported starting with Windows 8 and Windows Server 2012;
PROC_THREAD_ATTRIBUTE_JOB_LISTitself requires Windows 10 or Windows Server 2016 or later. Nested jobs aggregate accounting and propagate applicable notifications and termination through the hierarchy, but they do not add an admission barrier.^4^
Recommended containment and completion architecture
Treat job containment and creation completion as separate properties:
- Route every launch through a single long-lived broker.
- Persist or publish a request record before dispatching
CreateProcessW. - During shutdown, atomically stop accepting submissions and serialize that transition against request creation.
- Keep each request outstanding until
CreateProcessWreturns and the broker transfers the resulting process/thread handles and final status to the guardian. - If the broker dies with an outstanding request, retain the state as indeterminate; do not convert it to failure merely because the broker terminated.
- Use
PROC_THREAD_ATTRIBUTE_JOB_LISTfor containment, and use the application protocol—not job accounting—as the admission counter. - Permit no other component to receive or use assign-capable job handles outside that protocol. Otherwise, protocol closure cannot be authoritative.
- Optionally place the broker or an anchor process in a containing kill-on-close job. This reduces the risk of an uncontained survivor, but it still does not prove completion or cancellation of an interrupted admission.
A minimal transaction state model is:
record(request, Pending); // durable/shared state
if (!accepting_launches)
transition(request, Rejected);
else {
BOOL ok = CreateProcessW(/* JOB_LIST attributes */);
if (ok)
transfer_handles_and_mark(request, Succeeded);
else
mark(request, Failed, GetLastError());
}
// Broker death while Pending => Indeterminate, not Failed.
Authoritative clarification from Microsoft
Because rollback, pending-admission visibility, multi-job failure atomicity, and kill-on-close ordering are not specified by the public API contract, definitive reliance on those behaviors requires an official Microsoft Support case for Windows application development. Request escalation to the Windows process/job-object engineering or documentation team and ask for one of:
- a documented supported contract;
- an explicit statement that no supported guarantee exists; or
- a documentation clarification covering interrupted
CreateProcessW, multi-job rollback,TerminateJobObject, and final-handle-close ordering.
Until such a contract is supplied, distinguish contained/observably empty from creation protocol conclusively completed.
References
- UpdateProcThreadAttribute function (processthreadsapi.h)
- February 9, 2023 - The Old New Thing
- CreateProcessW function (processthreadsapi.h)
- Nested Jobs
- JOBOBJECT_BASIC_ACCOUNTING_INFORMATION structure (winnt.h)
- JOBOBJECT_BASIC_PROCESS_ID_LIST structure (winnt.h)
- JOBOBJECT_ASSOCIATE_COMPLETION_PORT structure (winnt.h)
- TerminateJobObject function (jobapi2.h)
- AssignProcessToJobObject function (jobapi2.h)
- JOBOBJECT_BASIC_LIMIT_INFORMATION structure (winnt.h)