Skip to content

Commit

Permalink
Merge pull request #94 from walquis/master
Browse files Browse the repository at this point in the history
Apply a fix similar to 6b16991 'ps -p', no space before dash-p option ar...
  • Loading branch information
FooBarWidget committed Feb 4, 2014
2 parents 4bbcd93 + f55f1f5 commit 8118630
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ext/common/Utils/ProcessMetricsCollector.h
Expand Up @@ -450,14 +450,16 @@ class ProcessMetricsCollector {
if (pidsArg[pidsArg.size() - 1] == ',') {
pidsArg.resize(pidsArg.size() - 1);
}

string fmtArg = "-o";
#if defined(sun) || defined(__sun)
fmtArg.append("pid,ppid,pcpu,rss,vsz,pgid,uid,args");
#else
fmtArg.append("pid,ppid,%cpu,rss,vsize,pgid,uid,command");
#endif

const char *command[] = {
"ps", "-o",
#if defined(sun) || defined(__sun)
"pid,ppid,pcpu,rss,vsz,pgid,uid,args",
#else
"pid,ppid,%cpu,rss,vsize,pgid,uid,command",
#endif
"ps", fmtArg.c_str(),
#ifdef PS_SUPPORTS_MULTIPLE_PIDS
pidsArg.c_str(),
#endif
Expand All @@ -469,6 +471,7 @@ class ProcessMetricsCollector {
psOutput = runCommandAndCaptureOutput(command);
}
pidsArg.resize(0);
fmtArg.resize(0);
ProcessMetricMap result = parsePsOutput<Collection, ConstIterator>(psOutput, pids);
psOutput.resize(0);
if (canMeasureRealMemory) {
Expand Down

0 comments on commit 8118630

Please sign in to comment.