@@ -72,7 +72,6 @@ describe.skipIf(process.platform === "win32")("qa scenario command real POSIX li
7272 it ( "settles within a bound after the leader writes its final result with inherited stdio open" , async ( ) => {
7373 const root = await mkdtemp ( path . join ( os . tmpdir ( ) , "qa-command-settlement-" ) ) ;
7474 const descendantPidPath = path . join ( root , "descendant.pid" ) ;
75- let descendantPid : number | undefined ;
7675 spawnMock . mockImplementation ( ( ...args : Parameters < NonNullable < typeof actualSpawn . value > > ) => {
7776 if ( ! actualSpawn . value ) {
7877 throw new Error ( "real spawn unavailable" ) ;
@@ -102,7 +101,7 @@ describe.skipIf(process.platform === "win32")("qa scenario command real POSIX li
102101 env : process . env ,
103102 timeoutMs : 5_000 ,
104103 } ) ;
105- descendantPid = await waitForPidFile ( descendantPidPath ) ;
104+ await waitForPidFile ( descendantPidPath ) ;
106105 const startedAt = Date . now ( ) ;
107106 const deadline = new AbortController ( ) ;
108107 const result = await Promise . race ( [
@@ -113,20 +112,15 @@ describe.skipIf(process.platform === "win32")("qa scenario command real POSIX li
113112 ] ) . finally ( ( ) => deadline . abort ( ) ) ;
114113
115114 expect ( Date . now ( ) - startedAt ) . toBeLessThan ( 1_500 ) ;
115+ // The exact result proves cleanup succeeded. A later numeric PID probe can
116+ // race PID reuse and inspect an unrelated process.
116117 expect ( result ) . toEqual ( {
117118 exitCode : 7 ,
118119 signal : null ,
119120 stdout : "Docker scheduling finished\ndelayed descendant output\n" ,
120121 stderr : "" ,
121122 } ) ;
122- if ( descendantPid === undefined ) {
123- throw new Error ( "scenario command descendant did not expose its pid" ) ;
124- }
125- await waitForDead ( descendantPid ) ;
126123 } finally {
127- if ( descendantPid && isProcessAlive ( descendantPid ) ) {
128- process . kill ( descendantPid , "SIGKILL" ) ;
129- }
130124 await rm ( root , { force : true , recursive : true } ) ;
131125 }
132126 } ) ;
0 commit comments