From 9c5025cddd465bc9c7d396552c7d1308ed8eecf0 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Mon, 25 Dec 2017 02:17:18 -0600 Subject: [PATCH] Only include the required output in ps On mac, lx includes: -l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD. On mac, the ps output can be misaligned, e.g. when some VSZ field is longer than expected. VSZ and many others of these fields are unnecessary because we're looking up by name, pid, ppid, or arguments only. Here I select those directly. This requires neekey/table-parser#12 which was released in table-parser 1.0.0+ --- lib/index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 893c57b..a2da45f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -118,7 +118,7 @@ exports.lookup = function (query, callback) { /** * add 'lx' as default ps arguments, since the default ps output in linux like "ubuntu", wont include command arguments */ - var exeArgs = query.psargs || ['lx']; + var exeArgs = query.psargs || 'x -o ppid,pid,command'; var filter = {}; var idList; diff --git a/package.json b/package.json index d0ec26a..12e8d5b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "pid" ], "dependencies": { - "table-parser": "^0.1.3" + "table-parser": "^1.0.1" }, "license": "MIT", "devDependencies": {