static int dump(ProcFamilyClient& pfc, int argc, char* argv[]) { if (argc > 2) { fprintf(stderr, "error: argument synopsis for %s: [<pid>]\n", argv[0]); return 1; } pid_t pid = 0; if (argc == 2) { pid = atoi(argv[1]); if (pid == 0) { fprintf(stderr, "error: invalid pid: %s\n", argv[1]); return 1; } } bool response; std::vector<ProcFamilyDump> vec; if (!pfc.dump(pid, response, vec)) { fprintf(stderr, "error: communication error with ProcD\n"); return 1; } if (!response) { fprintf(stderr, "error: %s command failed with ProcD\n", argv[0]); return 1; } for (size_t i = 0; i < vec.size(); ++i) { printf("%u %u %u %d\n", (unsigned)vec[i].parent_root, (unsigned)vec[i].root_pid, (unsigned)vec[i].watcher_pid, (int)vec[i].procs.size()); for (size_t j = 0; j < vec[i].procs.size(); ++j) { printf("%u %u " PROCAPI_BIRTHDAY_FORMAT " %ld %ld\n", (unsigned)vec[i].procs[j].pid, (unsigned)vec[i].procs[j].ppid, vec[i].procs[j].birthday, vec[i].procs[j].user_time, vec[i].procs[j].sys_time); } } return 0; }