@@ -23,26 +23,28 @@ describe('listAgentProcesses', () => {
2323 mockedExecFileSync . mockReset ( ) ;
2424 } ) ;
2525
26- it ( 'should parse ps aux | grep output and post-filter by executable name' , ( ) => {
26+ it ( 'should parse ps output and post-filter by executable name' , ( ) => {
2727 mockedExecFileSync . mockReturnValue (
28- 'user 78070 1.0 0.5 485636016 245952 s018 S+ 11:18PM 1:55.14 claude\n' +
29- 'user 55106 0.1 0.4 485620368 72496 s015 S+ 9Mar26 8:06.36 claude\n' ,
28+ '78070 1 s018 claude\n' +
29+ '55106 55100 s015 claude\n' ,
3030 ) ;
3131
3232 const processes = listAgentProcesses ( 'claude' ) ;
3333 expect ( processes ) . toHaveLength ( 2 ) ;
3434 expect ( processes [ 0 ] . pid ) . toBe ( 78070 ) ;
35+ expect ( processes [ 0 ] . ppid ) . toBe ( 1 ) ;
3536 expect ( processes [ 0 ] . command ) . toBe ( 'claude' ) ;
3637 expect ( processes [ 0 ] . tty ) . toBe ( 's018' ) ;
3738 expect ( processes [ 0 ] . cwd ) . toBe ( '' ) ; // not populated yet
3839 expect ( processes [ 1 ] . pid ) . toBe ( 55106 ) ;
40+ expect ( processes [ 1 ] . ppid ) . toBe ( 55100 ) ;
3941 } ) ;
4042
4143 it ( 'should filter out non-matching executables' , ( ) => {
4244 mockedExecFileSync . mockReturnValue (
43- 'user 100 0.0 0.0 0 0 s001 S 1:00PM 0:00 claude\n' +
44- 'user 200 0.0 0.0 0 0 s002 S 1:00PM 0:00 claude-helper --pid 100\n' +
45- 'user 300 0.0 0.0 0 0 s003 S 1:00PM 0:00 /usr/bin/claude\n' ,
45+ '100 1 s001 claude\n' +
46+ '200 1 s002 claude-helper --pid 100\n' +
47+ '300 1 s003 /usr/bin/claude\n' ,
4648 ) ;
4749
4850 const processes = listAgentProcesses ( 'claude' ) ;
@@ -75,7 +77,11 @@ describe('listAgentProcesses', () => {
7577 it ( 'should accept valid patterns with dashes and underscores' , ( ) => {
7678 mockedExecFileSync . mockReturnValue ( '' ) ;
7779 listAgentProcesses ( 'claude-code' ) ;
78- expect ( mockedExecFileSync ) . toHaveBeenCalled ( ) ;
80+ expect ( mockedExecFileSync ) . toHaveBeenCalledWith (
81+ 'ps' ,
82+ [ '-axo' , 'pid=,ppid=,tty=,command=' ] ,
83+ { encoding : 'utf-8' } ,
84+ ) ;
7985
8086 mockedExecFileSync . mockReset ( ) ;
8187 mockedExecFileSync . mockReturnValue ( '' ) ;
0 commit comments