1 /*
2 htop - UnsupportedProcessList.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
8 #include "UnsupportedProcessList.h"
9
10 #include <stdlib.h>
11 #include <string.h>
12
13 #include "ProcessList.h"
14 #include "UnsupportedProcess.h"
15
16
ProcessList_new(UsersTable * usersTable,Hashtable * dynamicMeters,Hashtable * dynamicColumns,Hashtable * pidMatchList,uid_t userId)17 ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* dynamicMeters, Hashtable* dynamicColumns, Hashtable* pidMatchList, uid_t userId) {
18 ProcessList* this = xCalloc(1, sizeof(ProcessList));
19 ProcessList_init(this, Class(Process), usersTable, dynamicMeters, dynamicColumns, pidMatchList, userId);
20
21 this->existingCPUs = 1;
22 this->activeCPUs = 1;
23
24 return this;
25 }
26
ProcessList_delete(ProcessList * this)27 void ProcessList_delete(ProcessList* this) {
28 ProcessList_done(this);
29 free(this);
30 }
31
ProcessList_goThroughEntries(ProcessList * super,bool pauseProcessUpdate)32 void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
33
34 // in pause mode only gather global data for meters (CPU/memory/...)
35 if (pauseProcessUpdate) {
36 return;
37 }
38
39 bool preExisting = true;
40 Process* proc;
41
42 proc = ProcessList_getProcess(super, 1, &preExisting, UnsupportedProcess_new);
43
44 /* Empty values */
45 proc->time = proc->time + 10;
46 proc->pid = 1;
47 proc->ppid = 1;
48 proc->tgid = 0;
49
50 Process_updateComm(proc, "commof16char");
51 Process_updateCmdline(proc, "<unsupported architecture>", 0, 0);
52 Process_updateExe(proc, "/path/to/executable");
53
54 if (proc->settings->flags & PROCESS_FLAG_CWD) {
55 free_and_xStrdup(&proc->procCwd, "/current/working/directory");
56 }
57
58 proc->updated = true;
59
60 proc->state = RUNNING;
61 proc->isKernelThread = false;
62 proc->isUserlandThread = false;
63 proc->show = true; /* Reflected in proc->settings-> "hideXXX" really */
64 proc->pgrp = 0;
65 proc->session = 0;
66 proc->tty_nr = 0;
67 proc->tty_name = NULL;
68 proc->tpgid = 0;
69 proc->processor = 0;
70
71 proc->percent_cpu = 2.5;
72 proc->percent_mem = 2.5;
73
74 proc->st_uid = 0;
75 proc->user = "nobody"; /* Update whenever proc->st_uid is changed */
76
77 proc->priority = 0;
78 proc->nice = 0;
79 proc->nlwp = 1;
80 proc->starttime_ctime = 1433116800; // Jun 01, 2015
81 Process_fillStarttimeBuffer(proc);
82
83 proc->m_virt = 100;
84 proc->m_resident = 100;
85
86 proc->minflt = 20;
87 proc->majflt = 20;
88
89 if (!preExisting)
90 ProcessList_add(super, proc);
91 }
92
ProcessList_isCPUonline(const ProcessList * super,unsigned int id)93 bool ProcessList_isCPUonline(const ProcessList* super, unsigned int id) {
94 assert(id < super->existingCPUs);
95
96 (void) super; (void) id;
97
98 return true;
99 }
100