Thank you for detailed post.
Microsoft documents job assignment before initial-thread execution, but I could not find an explicit API-reference guarantee covering the complete outcome when the caller terminates during CreateProcessW. Those are distinct claims.
On each of your questions:
First, The UpdateProcThreadAttribute reference documents PROC_THREAD_ATTRIBUTE_JOB_LIST as specifying the jobs to which the child process is assigned.
Microsoft also publishes a more explicit explanation in Raymond Chen’s article, “A more direct and mistake-free way of creating a process in a job object”.
It states that assignment occurs before the initial thread is allowed to run. The article specifically discusses the risk of orphaned processes when the creator crashes between creating a suspended process and assigning it to a job and presents this attribute as the solution.
Therefore, assignment before execution is supported by published Microsoft guidance. However, the article does not expressly define the outcome at every interruption point when the caller dies inside CreateProcessW. Under your requirement for an explicit API contract addressing that exact scenario, I cannot cite such a statement.
This documentation gap does not establish that a surviving child can actually run outside the specified job. Claiming that it can would also require evidence.
Second, the CreateProcessW reference does not specify a transactional cleanup or rollback guarantee for termination of the calling process while the call is in progress. I could not find an explicit statement restricting that scenario to your two proposed outcomes.
General process-termination documentation says the terminating process’s handles are closed and that terminating a parent does not itself terminate its children. These rules do not establish what happens to every partially completed process-creation operation.
Your retained-handle assumption is also correct: JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE triggers when the last job handle closes. With another process retaining a handle, it supplies no automatic termination in response to the caller’s death.
Consequently, the exact interrupted-call cleanup outcome is not explicitly specified by these API references.
And Microsoft documents support for PROC_THREAD_ATTRIBUTE_JOB_LIST beginning with Windows 10 and Windows Server 2016, and continuing in newer versions. These are feature-availability requirements, not a separate guarantee about caller termination during creation. See the attribute’s entry in UpdateProcThreadAttribute.
I could not identify a Microsoft API reference naming a Windows version or build that expressly guarantees your exact two-outcome property. If your design requires that property as an explicit operating-system contract, the remaining step is to obtain Microsoft clarification covering this precise failure scenario and the intended deployment versions.
If you found my investigation and direction of my support helpful, I’d really appreciate it if you could follow this guide so others with similar issue can benefit as well.
Thank you.