UnsupportedProcessTable.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. htop - UnsupportedProcessTable.c
  3. (C) 2014 Hisham H. Muhammad
  4. Released under the GNU GPLv2+, see the COPYING file
  5. in the source distribution for its full text.
  6. */
  7. #include "config.h" // IWYU pragma: keep
  8. #include "UnsupportedProcessTable.h"
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include "ProcessTable.h"
  12. #include "UnsupportedProcess.h"
  13. ProcessTable* ProcessTable_new(Machine* host, Hashtable* pidMatchList) {
  14. UnsupportedProcessTable* this = xCalloc(1, sizeof(UnsupportedProcessTable));
  15. Object_setClass(this, Class(ProcessTable));
  16. ProcessTable* super = &this->super;
  17. ProcessTable_init(super, Class(Process), host, pidMatchList);
  18. return this;
  19. }
  20. void ProcessTable_delete(Object* cast) {
  21. UnsupportedProcessTable* this = (UnsupportedProcessTable*) cast;
  22. ProcessTable_done(&this->super);
  23. free(this);
  24. }
  25. void ProcessTable_goThroughEntries(ProcessTable* super) {
  26. bool preExisting = true;
  27. Process* proc;
  28. proc = ProcessTable_getProcess(super, 1, &preExisting, UnsupportedProcess_new);
  29. /* Empty values */
  30. proc->time = proc->time + 10;
  31. Process_setPid(proc, 1);
  32. Process_setParent(proc, 1);
  33. Process_setThreadGroup(proc, 0);
  34. Process_updateComm(proc, "commof16char");
  35. Process_updateCmdline(proc, "<unsupported architecture>", 0, 0);
  36. Process_updateExe(proc, "/path/to/executable");
  37. const Settings* settings = proc->host->settings;
  38. if (settings->ss->flags & PROCESS_FLAG_CWD) {
  39. free_and_xStrdup(&proc->procCwd, "/current/working/directory");
  40. }
  41. proc->super.updated = true;
  42. proc->state = RUNNING;
  43. proc->isKernelThread = false;
  44. proc->isUserlandThread = false;
  45. proc->super.show = true; /* Reflected in settings-> "hideXXX" really */
  46. proc->pgrp = 0;
  47. proc->session = 0;
  48. proc->tty_nr = 0;
  49. proc->tty_name = NULL;
  50. proc->tpgid = 0;
  51. proc->processor = 0;
  52. proc->percent_cpu = 2.5;
  53. proc->percent_mem = 2.5;
  54. Process_updateCPUFieldWidths(proc->percent_cpu);
  55. proc->st_uid = 0;
  56. proc->user = "nobody"; /* Update whenever proc->st_uid is changed */
  57. proc->priority = 0;
  58. proc->nice = 0;
  59. proc->nlwp = 1;
  60. proc->starttime_ctime = 1433116800; // Jun 01, 2015
  61. Process_fillStarttimeBuffer(proc);
  62. proc->m_virt = 100;
  63. proc->m_resident = 100;
  64. proc->minflt = 20;
  65. proc->majflt = 20;
  66. if (!preExisting)
  67. ProcessTable_add(super, proc);
  68. }