@@ -1534,15 +1534,17 @@ function networkConnections(callback) {
15341534 } ) ;
15351535 }
15361536 if ( _darwin ) {
1537- // let cmd = 'netstat -natv | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN"';
1538- let cmd = 'netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6"' ;
1537+ let cmd = 'netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6\\|Recv-Q"' ;
15391538 const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT_1|FIN_WAIT2|FIN_WAIT_2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN' ;
15401539 exec ( cmd , { maxBuffer : 1024 * 20000 } , function ( error , stdout ) {
15411540 if ( ! error ) {
15421541 exec ( 'ps -axo pid,command' , { maxBuffer : 1024 * 20000 } , function ( err2 , stdout2 ) {
15431542 let processes = stdout2 . toString ( ) . split ( '\n' ) ;
15441543 processes = processes . map ( ( line => { return line . trim ( ) . replace ( / + / g, ' ' ) ; } ) ) ;
15451544 let lines = stdout . toString ( ) . split ( '\n' ) ;
1545+ const header = lines [ 0 ] ;
1546+ const hasTransferred = header . indexOf ( 'rxbytes' ) > - 1 ;
1547+ lines . shift ( ) ;
15461548
15471549 lines . forEach ( function ( line ) {
15481550 line = line . replace ( / + / g, ' ' ) . split ( ' ' ) ;
@@ -1565,7 +1567,7 @@ function networkConnections(callback) {
15651567 }
15661568 const hasState = states . indexOf ( line [ 5 ] ) >= 0 ;
15671569 let connstate = hasState ? line [ 5 ] : 'UNKNOWN' ;
1568- let pid = parseInt ( line [ 8 + ( hasState ? 0 : - 1 ) ] , 10 ) ;
1570+ let pid = parseInt ( line [ 8 + ( hasState ? 0 : - 1 ) + ( hasTransferred ? 2 : 0 ) ] , 10 ) ;
15691571 if ( connstate ) {
15701572 result . push ( {
15711573 protocol : line [ 0 ] ,
0 commit comments