2015-03-16 06:16:18 +00:00
/*
htop - UnsupportedProcess . c
( C ) 2015 Hisham H . Muhammad
2020-10-05 07:51:32 +00:00
Released under the GNU GPLv2 , see the COPYING file
2015-03-16 06:16:18 +00:00
in the source distribution for its full text .
*/
2021-01-28 17:19:38 +00:00
# include "config.h" // IWYU pragma: keep
2015-03-16 06:16:18 +00:00
# include "UnsupportedProcess.h"
2021-01-28 17:19:38 +00:00
2015-03-16 06:16:18 +00:00
# include <stdlib.h>
2021-01-28 17:19:38 +00:00
# include "CRT.h"
# include "Process.h"
2020-12-15 18:44:52 +00:00
const ProcessFieldData Process_fields [ LAST_PROCESSFIELD ] = {
2020-12-13 14:52:32 +00:00
[ 0 ] = { . name = " " , . title = NULL , . description = NULL , . flags = 0 , } ,
2020-12-15 18:44:52 +00:00
[ PID ] = { . name = " PID " , . title = " PID " , . description = " Process/thread ID " , . flags = 0 , . pidColumn = true , } ,
2020-12-13 14:52:32 +00:00
[ COMM ] = { . name = " Command " , . title = " Command " , . description = " Command line " , . flags = 0 , } ,
[ STATE ] = { . name = " STATE " , . title = " S " , . description = " Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging) " , . flags = 0 , } ,
2020-12-15 18:44:52 +00:00
[ PPID ] = { . name = " PPID " , . title = " PPID " , . description = " Parent process ID " , . flags = 0 , . pidColumn = true , } ,
[ PGRP ] = { . name = " PGRP " , . title = " PGRP " , . description = " Process group ID " , . flags = 0 , . pidColumn = true , } ,
[ SESSION ] = { . name = " SESSION " , . title = " SID " , . description = " Process's session ID " , . flags = 0 , . pidColumn = true , } ,
2020-12-13 14:52:32 +00:00
[ TTY_NR ] = { . name = " TTY_NR " , . title = " TTY " , . description = " Controlling terminal " , . flags = 0 , } ,
2020-12-15 18:44:52 +00:00
[ TPGID ] = { . name = " TPGID " , . title = " TPGID " , . description = " Process ID of the fg process group of the controlling terminal " , . flags = 0 , . pidColumn = true , } ,
2021-01-21 13:27:23 +00:00
[ MINFLT ] = { . name = " MINFLT " , . title = " MINFLT " , . description = " Number of minor faults which have not required loading a memory page from disk " , . flags = 0 , . defaultSortDesc = true , } ,
[ MAJFLT ] = { . name = " MAJFLT " , . title = " MAJFLT " , . description = " Number of major faults which have required loading a memory page from disk " , . flags = 0 , . defaultSortDesc = true , } ,
2020-12-13 14:52:32 +00:00
[ PRIORITY ] = { . name = " PRIORITY " , . title = " PRI " , . description = " Kernel's internal priority for the process " , . flags = 0 , } ,
[ NICE ] = { . name = " NICE " , . title = " NI " , . description = " Nice value (the higher the value, the more it lets other processes take priority) " , . flags = 0 , } ,
[ STARTTIME ] = { . name = " STARTTIME " , . title = " START " , . description = " Time the process was started " , . flags = 0 , } ,
[ PROCESSOR ] = { . name = " PROCESSOR " , . title = " CPU " , . description = " Id of the CPU the process last executed on " , . flags = 0 , } ,
2021-01-21 13:27:23 +00:00
[ M_VIRT ] = { . name = " M_VIRT " , . title = " VIRT " , . description = " Total program size in virtual memory " , . flags = 0 , . defaultSortDesc = true , } ,
[ M_RESIDENT ] = { . name = " M_RESIDENT " , . title = " RES " , . description = " Resident set size, size of the text and data sections, plus stack usage " , . flags = 0 , . defaultSortDesc = true , } ,
2020-12-13 14:52:32 +00:00
[ ST_UID ] = { . name = " ST_UID " , . title = " UID " , . description = " User ID of the process owner " , . flags = 0 , } ,
2021-01-21 13:27:23 +00:00
[ PERCENT_CPU ] = { . name = " PERCENT_CPU " , . title = " CPU% " , . description = " Percentage of the CPU time the process used in the last sampling " , . flags = 0 , . defaultSortDesc = true , } ,
[ PERCENT_MEM ] = { . name = " PERCENT_MEM " , . title = " MEM% " , . description = " Percentage of the memory the process is using, based on resident memory size " , . flags = 0 , . defaultSortDesc = true , } ,
2020-12-13 14:52:32 +00:00
[ USER ] = { . name = " USER " , . title = " USER " , . description = " Username of the process owner (or user ID if name cannot be determined) " , . flags = 0 , } ,
2021-01-21 13:27:23 +00:00
[ TIME ] = { . name = " TIME " , . title = " TIME+ " , . description = " Total time the process has spent in user and system time " , . flags = 0 , . defaultSortDesc = true , } ,
2020-12-13 14:52:32 +00:00
[ NLWP ] = { . name = " NLWP " , . title = " NLWP " , . description = " Number of threads in the process " , . flags = 0 , } ,
2020-12-15 18:44:52 +00:00
[ TGID ] = { . name = " TGID " , . title = " TGID " , . description = " Thread group ID (i.e. process ID) " , . flags = 0 , . pidColumn = true , } ,
2020-12-13 14:52:32 +00:00
} ;
2015-03-16 06:16:18 +00:00
2021-01-28 17:19:38 +00:00
Process * UnsupportedProcess_new ( const Settings * settings ) {
Process * this = xCalloc ( 1 , sizeof ( UnsupportedProcess ) ) ;
Object_setClass ( this , Class ( UnsupportedProcess ) ) ;
2015-07-12 16:26:33 +00:00
Process_init ( this , settings ) ;
2015-03-16 06:16:18 +00:00
return this ;
}
2021-01-28 17:19:38 +00:00
void Process_delete ( Object * cast ) {
Process * super = ( Process * ) cast ;
Process_done ( super ) ;
2015-03-16 06:16:18 +00:00
// free platform-specific fields here
2021-01-28 17:19:38 +00:00
free ( cast ) ;
}
static void UnsupportedProcess_writeField ( const Process * this , RichString * str , ProcessField field ) {
const UnsupportedProcess * up = ( const UnsupportedProcess * ) this ;
bool coloring = this - > settings - > highlightMegabytes ;
char buffer [ 256 ] ; buffer [ 255 ] = ' \0 ' ;
int attr = CRT_colors [ DEFAULT_COLOR ] ;
size_t n = sizeof ( buffer ) - 1 ;
( void ) up ;
( void ) coloring ;
( void ) n ;
switch ( field ) {
/* Add platform specific fields */
default :
Process_writeField ( this , str , field ) ;
return ;
}
RichString_appendWide ( str , attr , buffer ) ;
}
static int UnsupportedProcess_compareByKey ( const Process * v1 , const Process * v2 , ProcessField key ) {
const UnsupportedProcess * p1 = ( const UnsupportedProcess * ) v1 ;
const UnsupportedProcess * p2 = ( const UnsupportedProcess * ) v2 ;
( void ) p1 ;
( void ) p2 ;
switch ( key ) {
/* Add platform specific fields */
default :
return Process_compareByKey_Base ( v1 , v2 , key ) ;
}
2015-03-16 06:16:18 +00:00
}
2021-01-28 17:19:38 +00:00
const ProcessClass UnsupportedProcess_class = {
. super = {
. extends = Class ( Process ) ,
. display = Process_display ,
. delete = Process_delete ,
. compare = Process_compare
} ,
. writeField = UnsupportedProcess_writeField ,
. getCommandStr = NULL ,
. compareByKey = UnsupportedProcess_compareByKey
} ;