Hi @Peter Geyer ,
After reviewing on your questions and the available Microsoft documentations, here are my answers:
The Win32 Job Objects documentation specifies normal job inheritance and termination of associated processes. It does not specify what happens to a partially created child if S dies inside CreateProcessW, or how that creation is ordered against concurrent job teardown.
1. Must every surviving child belong to J_G?
For ordinary CreateProcessW creation with no breakaway, the child inherits the parent’s job. CREATE_SUSPENDED keeps the primary thread from running until resumed; it does not guarantee rollback. The public references neither enumerate the possible outcomes of an interrupted call nor establish that an unassigned child can survive.
2. What if R tears down the job concurrently?
TerminateJobObject covers processes currently associated with the job and its child jobs. Closing the last handle with KILL_ON_JOB_CLOSE also terminates associated processes, including suspended members. Neither reference specifies how teardown is ordered against an association still in flight, so the docs neither establish nor rule out a late, uncontained child in this scenario.
3. Is waiting for S enough?
Waiting on S’s process handle confirms that S terminated, not that every child creation it initiated completed or rolled back. I found no documented Win32 wait that provides that broader guarantee after abrupt creator termination.
4. Can R verify membership without sharing the job handle?
Yes, for a known child. R can call IsProcessInJob using its existing JOB_OBJECT_QUERY handle and a query-capable child process handle. Passing NULL checks membership in any job, not specifically J_G. R can also list the job’s member PIDs, including nested members, but that list cannot account for an unknown child outside the job.
Because the public documentation does not define how interrupted process creation interacts with concurrent job termination, I recommend opening a case with Microsoft Support for Business. They can advise whether the question can be routed to Windows engineering for clarification. Please note that this is a paid support option.
I hope this helps clarifying your requirements and answering your questions. If you find my response helpful, I would greatly appreciate it if you could follow the guide here so others experiencing similar behavior can benefit from it as well.