@@ -9,6 +9,7 @@ import { createSubsystemLogger } from "../logging/subsystem.js";
99import { isGatewayArgv , parseProcCmdline } from "./gateway-process-argv.js" ;
1010import { parseStrictPositiveInteger } from "./parse-finite-number.js" ;
1111import { resolveLsofCommandSync } from "./ports-lsof.js" ;
12+ import { spawnPsSync } from "./spawn-ps.js" ;
1213import { getWindowsInstallRoots } from "./windows-install-roots.js" ;
1314import {
1415 readWindowsListeningPidsOnPortSync ,
@@ -109,10 +110,7 @@ function readParentPidFromProc(pid: number): number | null {
109110
110111function readParentPidFromPs ( pid : number , spawnTimeoutMs : number ) : number | null {
111112 try {
112- const res = spawnSync ( "ps" , [ "-o" , "ppid=" , "-p" , String ( pid ) ] , {
113- encoding : "utf8" ,
114- timeout : spawnTimeoutMs ,
115- } ) ;
113+ const res = spawnPsSync ( [ "-o" , "ppid=" , "-p" , String ( pid ) ] , spawnTimeoutMs ) ;
116114 if ( res . error || res . status !== 0 || ! res . stdout . trim ( ) ) {
117115 return null ;
118116 }
@@ -251,10 +249,7 @@ function readUnixProcessArgsSync(pid: number, spawnTimeoutMs: number): string[]
251249 // Fall back to ps below; /proc may be unavailable or restricted.
252250 }
253251 }
254- const res = spawnSync ( "ps" , [ "-ww" , "-p" , String ( pid ) , "-o" , "command=" ] , {
255- encoding : "utf8" ,
256- timeout : spawnTimeoutMs ,
257- } ) ;
252+ const res = spawnPsSync ( [ "-ww" , "-p" , String ( pid ) , "-o" , "command=" ] , spawnTimeoutMs ) ;
258253 if ( res . error || res . status !== 0 || ! res . stdout . trim ( ) ) {
259254 return null ;
260255 }
0 commit comments