A issue reported:
I’m porting my program to osX, and found a bug in ps-node.
On osX, commands path may contain spaces. For instance I’m trying to find ocurrences of Google Chrome, and here is an example of ‘ps -A’ command output:
Mac-Mini:herve$ ps -A
PID TTY TIME CMD
54292 ?? 0:01.00 /Applications/Google Chrome.app/Contents/Versions/47.0
54359 ?? 0:02.96 /Applications/Google Chrome.app/Contents/Versions/47.0
54391 ?? 0:01.41 /Applications/Google Chrome.app/Contents/Versions/47.0
54694 ?? 0:00.87 /Applications/Google Chrome.app/Contents/Versions/47.0
See the space between ‘Google' and ‘Chrome’?
You obviously use the space to separate the command from its arguments, which is wrong on osX. The resulting object of your parsing contains (for instance):
{ pid: '54359',
command: '/Applications/Google',
arguments:
[ 'Chrome.app/Contents/Versions/47.0.2526.106/Google',
'Chrome',
'Helper.app/Contents/MacOS/Google',
'Chrome',
'Helper',
'--type=renderer',
'--enable-experimental-web-platform-features',
'--lang=fr' ],
ppid: undefined }
I suppose that you could replace the line in table-parser/lib/index.js
var fields = line.split( /\s+/ );
by something like:
var fields = line.split( /[^\/]\s+[^\/]/ ); // not tested so it doesn’t work :-)
to eliminate the spaces between slashes inside fields. This may benefit to arguments too, since they can contain a path with a space.
I didn’t check the bug on previous versions of ps-node.
A issue reported:
I’m porting my program to osX, and found a bug in ps-node.
On osX, commands path may contain spaces. For instance I’m trying to find ocurrences of Google Chrome, and here is an example of ‘ps -A’ command output:
See the space between ‘Google' and ‘Chrome’?
You obviously use the space to separate the command from its arguments, which is wrong on osX. The resulting object of your parsing contains (for instance):
I suppose that you could replace the line in table-parser/lib/index.js
by something like:
to eliminate the spaces between slashes inside fields. This may benefit to arguments too, since they can contain a path with a space.
I didn’t check the bug on previous versions of ps-node.