nl_tokens: Get the IDs of processes listening on the particular system port . It is also possible to apply additional filtering based on the process command line .
pl_tokens: async function getPIDsListeningOnPort ( port , filteringFunc = null ) { const result = [ ] ; try { // This only works since Mac OS X El Capitan const { stdout } = await exec ( 'lsof' , [ '-ti' , ` ${ port } ` ] ) ; result . push ( ... ( stdout . trim ( ) . <mask> ( / \n+ / ) ) ) ; } catch ( e ) { return result ; } if ( ! _ . isFunction ( filteringFunc ) ) { return result ; } return await B . filter ( result , async ( x ) => { const { stdout } = await exec ( 'ps' , [ '-p' , x , '-o' , 'command' ] ) ; return await filteringFunc ( stdout ) ; } ) ; }