@@ -288,10 +288,10 @@ switch (args[1]) {
288288 ) ;
289289 yield * fs . writeFileString (
290290 path . join ( directory , "ps" ) ,
291- '#!/bin/sh\nif [ "$T3_FIXTURE_ZOMBIE" = "1 " ]; then printf Z; else exec /bin/ps "$@"; fi\n' ,
291+ '#!/bin/sh\nfor arg do pid="$arg"; done\ nif [ -n "$T3_FIXTURE_ZOMBIE_PID" ] && [ "$pid" = "$T3_FIXTURE_ZOMBIE_PID " ]; then printf Z; else exec /bin/ps "$@"; fi\n' ,
292292 { mode : 0o700 } ,
293293 ) ;
294- let zombie = "0 " ;
294+ let zombiePid = "" ;
295295 let readyPort = "41773" ;
296296 const localSsh = ChildProcessSpawner . make ( ( command ) => {
297297 assert . strictEqual ( command . _tag , "StandardCommand" ) ;
@@ -302,7 +302,7 @@ switch (args[1]) {
302302 env : {
303303 HOME : directory ,
304304 PATH : `${ directory } :/usr/bin:/bin` ,
305- T3_FIXTURE_ZOMBIE : zombie ,
305+ T3_FIXTURE_ZOMBIE_PID : zombiePid ,
306306 T3CODE_HOME : customHome ,
307307 T3_FIXTURE_READY_PORT : readyPort ,
308308 T3_FIXTURE_STATE_DIR : stateDir ,
@@ -343,14 +343,37 @@ switch (args[1]) {
343343 yield * fs . readFileString ( path . join ( stateDir , "run-t3.sh" ) ) ,
344344 "old runner stays intact" ,
345345 ) ;
346- zombie = "1" ;
346+ zombiePid = String ( external . pid ) ;
347347 readyPort = "41774" ;
348348 assert . deepEqual ( yield * launch , { remotePort : 41774 , remoteServerKind : "managed" } ) ;
349349 assert . strictEqual (
350350 ( yield * fs . readFileString ( path . join ( stateDir , "server-home" ) ) ) . trim ( ) ,
351351 customHome ,
352352 ) ;
353353 assert . isTrue ( yield * external . isRunning ) ;
354+
355+ // A rejected runtime PID must not hide a live sibling on the selected home.
356+ const sibling = yield * realSpawner . spawn (
357+ ChildProcess . make ( process . execPath , [
358+ "-e" ,
359+ "process.stdin.resume()" ,
360+ "--" ,
361+ "serve" ,
362+ "--host" ,
363+ "127.0.0.1" ,
364+ "--port" ,
365+ "41775" ,
366+ ] ) ,
367+ ) ;
368+ const siblingDir = path . join ( directory , ".t3/ssh-launch" , "sibling" ) ;
369+ yield * fs . makeDirectory ( siblingDir , { recursive : true } ) ;
370+ yield * fs . writeFileString ( path . join ( siblingDir , "managed" ) , "managed" ) ;
371+ yield * fs . writeFileString ( path . join ( siblingDir , "pid" ) , String ( sibling . pid ) ) ;
372+ yield * fs . writeFileString ( path . join ( siblingDir , "port" ) , "41775" ) ;
373+ yield * fs . writeFileString ( path . join ( siblingDir , "server-home" ) , customHome ) ;
374+ readyPort = "41775" ;
375+ assert . deepEqual ( yield * launch , { remotePort : 41775 , remoteServerKind : "external" } ) ;
376+ assert . isTrue ( yield * sibling . isRunning ) ;
354377 } ) . pipe ( Effect . scoped , Effect . provide ( Layer . mergeAll ( NodeServices . layer , NodeCrypto . layer ) ) ) ,
355378 ) ;
356379
0 commit comments