Skip to content

stdout of ChildProcess.exec("ps") is cut short not giving the complete args to process #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
peteroreil opened this issue Apr 11, 2017 · 1 comment

Comments

@peteroreil
Copy link

peteroreil commented Apr 11, 2017

Found on version 0.1.4
/lib/index.js Line 74

If a process is started with a particularly long argument/ multiple arguments,

e.g.node /really/long/absolute/path/to/my/script/myscriptname.js

The object returned ps.lookup for that process will return a truncated version of the
argument passed to the script e.g. /really/long/absolute/pa

` else {
ChildProcess.exec('ps ' + args, function (err, stdout, stderr) {

  if (err || stderr) {
    return callback(err || stderr.toString());
  }
  else {
    stdout = stdout.toString();
    callback(null, stdout || false);
  }
});`

Function that is causing the problem is the ChildProcess.exec.
Suggested solutions are to change from exec to spawn?

http://www.hacksparrow.com/difference-between-spawn-and-exec-of-node-js-child_process.html

Minor workaround is is to pass an option of { psargs: " " } to the lookup function to limit the size of
stdout returned

@neekey
Copy link
Owner

neekey commented Apr 21, 2017

@peteroreil this is a known issue for 0.1.4 you can switch to 0.1.5 for the moment, or wait for a few days I will release 0.1.6 soon which fixes a small issue brought in 0.1.5 for kill()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants