neekey / ps

A Node.js module for looking up running processes
MIT License
128 stars 41 forks source link

Regression introduced with v0.1.5 with BusyBox v1.22.1 #52

Open peteroreil opened 7 years ago

peteroreil commented 7 years ago

I'm using this library on an Intel Galileo, Which is running BusyBox v1.22.1 (2015-10-25 11:24:34 GMT) multi-call binary.

          var psNode = require('ps-node');

            psNode.lookup({ pid: pId }, function(err, resultList) {
                if(err) return reject(err);
                return done(resultList[0]);
            });

When I pass a running pId to the lookup function in v0.1.4, the resultList will return an array with the running process details.

When I pass a running pId to the lookup function in v0.1.5 the resultList will return an empty array.

ps usage options on busybox a.k.a none

root@hostname:~/peter/ps-mon# ps --help
BusyBox v1.22.1 (2015-10-25 11:24:34 GMT) multi-call binary.

Usage: ps 

ps table fields on BusyBox

PID USER VSZ STAT COMMAND

neekey commented 7 years ago

@peteroreil thanks for reporting this issue, I don't know much about BusyBox but can you clone this project and run test npm test with BusyBox first?

peteroreil commented 7 years ago

Actually need to update this ticket, recently learned (thanks to ps-node I might add) that ps on BusyBox does take options. ps l is a valid option.

peteroreil commented 7 years ago

@neekey ran tests on v0.1.5

 81 passing (6m)
  4 failing

  1) test #lookup() by id:

      Uncaught AssertionError: "/home/root/" == "/home/root/galileo-dsu/node_modules/ps-node/test/node_process_for_test.js"
      + expected - actual

      -/home/root/
      +/home/root/galileo-dsu/node_modules/ps-node/test/node_process_for_test.js

      at test/test.js:53:16
      at lib/index.js:182:7
      at ChildProcess.<anonymous> (lib/index.js:97:9)
      at Process.ChildProcess._handle.onexit (child_process.js:789:12)

  2) test #lookup() by command & arguments:

      Uncaught AssertionError: 0 == 1
      + expected - actual

      -0
      +1

      at test/test.js:61:16
      at lib/index.js:182:7
      at ChildProcess.<anonymous> (lib/index.js:97:9)
      at Process.ChildProcess._handle.onexit (child_process.js:789:12)

  3) test #lookup() by arguments, the matching should be case insensitive :

      Uncaught AssertionError: 0 == 1
      + expected - actual

      -0
      +1

      at test/test.js:70:16
      at lib/index.js:182:7
      at ChildProcess.<anonymous> (lib/index.js:97:9)
      at Process.ChildProcess._handle.onexit (child_process.js:789:12)

  4) test #lookup() should work correctly with options `aux`:
     Uncaught TypeError: Cannot read property 'length' of undefined
      at test/test.js:92:26
      at lib/index.js:156:14
      at ChildProcess.<anonymous> (lib/index.js:94:16)
      at Process.ChildProcess._handle.onexit (child_process.js:789:12)

I think you can mark this one as can't reproduce. Even those these tests are failing, these tests are still returning a process object.

The tests (Test 1 at least) that are failing are due issue #54 which I reported, which looks like is platform specific,

Regarding issue #54, the tests pass when I'm running on Ubuntu but BusyBox is not so co-operative. For some reason, the arguments array is shortened when running on BusyBox even though the output from the ps command shows the full argument list.

Thanks

neekey commented 7 years ago

Hi @peteroreil thanks for all these detailed info, really helps to figure out the issue!

So according to your report, my suspicions are:

alexmufatti commented 6 years ago

I think there is the same problem on MacOS. There is something wrong in the ps output parsing so that values are associated with the wrong column.

peteroreil commented 6 years ago

@neekey I'm sorry, I never seen this reply. :( The version of busybox I was using did not support aux options, just l