Index: trunk/tools/slayerd/slayerd.cc |
— | — | @@ -70,7 +70,10 @@ |
71 | 71 | process(fs::path const &pth); |
72 | 72 | |
73 | 73 | pid_t _pid; |
| 74 | + /* short command from /proc/{pid}/stat */ |
74 | 75 | std::string _comm; |
| 76 | + /* fulll command from /proc/{pid}/cmdline */ |
| 77 | + std::string _fullcomm; |
75 | 78 | char _state; |
76 | 79 | pid_t _ppid; |
77 | 80 | pid_t _pgrp; |
— | — | @@ -163,6 +166,17 @@ |
164 | 167 | if (!(f >> _msize >> _mres >> _mshare >> _mtext >> _mlib >> _mdata)) |
165 | 168 | throw std::runtime_error("could not parse statm line"); |
166 | 169 | } |
| 170 | + |
| 171 | + { |
| 172 | + std::ifstream f((pth / "cmdline").native_file_string().c_str()); |
| 173 | + std::string sline; |
| 174 | + |
| 175 | + if (!f) |
| 176 | + throw std::runtime_error("could not read line from cmdline"); |
| 177 | + |
| 178 | + if (!(f >> _fullcomm)) |
| 179 | + throw std::runtime_error("could not parse cmdline"); |
| 180 | + } |
167 | 181 | } |
168 | 182 | |
169 | 183 | std::string |
— | — | @@ -629,9 +643,14 @@ |
630 | 644 | |
631 | 645 | while (bytes >= config.thresh && !u.processes.empty()) { |
632 | 646 | process &p = u.processes[0]; |
| 647 | + |
| 648 | + /* command is (%s) formatted, strip parentheses. */ |
633 | 649 | std::string comm = p._comm.substr(1); |
634 | 650 | comm.resize(comm.size() - 1); |
635 | 651 | |
| 652 | + /* arguments are \0 separated, use spaces for display */ |
| 653 | + std::replace(p._fullcomm.begin(), p._fullcomm.end(), '\0', ' '); |
| 654 | + |
636 | 655 | if (!config.debug) |
637 | 656 | kill(p._pid, SIGKILL); |
638 | 657 | |
— | — | @@ -642,8 +661,8 @@ |
643 | 662 | % (thissize / 1024 / 1024) |
644 | 663 | % ((bytes - thissize) / 1024 / 1024))); |
645 | 664 | |
646 | | - process_list += str(boost::format(" %s (pid %d), using %d megabyte(s)\n") |
647 | | - % comm % p._pid % (thissize / 1024 / 1024)); |
| 665 | + process_list += str(boost::format(" %s (pid %d), using %d megabyte(s). Command was:\n \"%s\"\n") |
| 666 | + % comm % p._pid % (thissize / 1024 / 1024) % p._fullcomm); |
648 | 667 | |
649 | 668 | bytes -= thissize; |
650 | 669 | u.processes.erase(u.processes.begin()); |