Procster  0.1
Procster-ViewProcessesovertheweb
proctree.c File Reference

Transform a linear process list into a process tree. More...

#include <stdio.h>
#include <glib.h>
#include <time.h>
#include <jansson.h>
#include "proclister.h"
Include dependency graph for proctree.c:

Functions

void free_data (gpointer data)
 
void key_free (void *k)
 
void val_free (void *v)
 Merely show hastable iteration. More...
 
proc_tproc_tree (void)
 Populate a tree of (proc_t) processes. More...
 
void proc_htab_free (GHashTable *ht)
 

Detailed Description

Transform a linear process list into a process tree.

Dependencies

On Ubuntu / Debian:

sudo apt-get install libprocps6 libprocps-dev libglib2.0-dev libjansson4 libjansson-dev

Glib and jansson references

Compiling

gcc `pkg-config --cflags glib-2.0` foo.c `pkg-config --libs glib-2.0`
gcc foo.c `pkg-config --cflags --libs glib-2.0`


gcc -o proc proc.c -I/usr/include/glib-2.0 -lprocps  `pkg-config --cflags --libs glib-2.0`

Special flags for passing extras to openproc()

  • PROC_PID - Pass an array of PIDS (0-terminated piudlist) as 2nd arg (pid_t* pidlist)
  • PROC_UID - Pass (after PID:s) many UID:s followed by number of them.

See struct proc_t

less /usr/include/proc/readproc.h Notes on start_time: Ubuntu 18.04: start_time; // stat start time of process – seconds since 1-1-70 Gitlab (2021): start_time;// stat start time of process – seconds since system boot

Function Documentation

◆ free_data()

void free_data ( gpointer  data)

◆ key_free()

void key_free ( void *  k)

◆ proc_htab_free()

void proc_htab_free ( GHashTable *  ht)

◆ proc_tree()

proc_t* proc_tree ( void  )

Populate a tree of (proc_t) processes.

Because of intricate linkages of process tree - and not wanting them broken or incomplete - we do not support partial or filtered process trees (although the implementation contains some bulletproofing for this).

Returns
Root process node of the tree.

References g_slist_free(), main(), par_add_child(), proc_chn_init, PROC_FLAGS_DEFAULT, and ptree_dump().

Referenced by answer_to_connection0(), and proc_list_json2().

◆ val_free()

void val_free ( void *  v)

Merely show hastable iteration.

Intent is not to free this way as the process nodes are still used within tree structure (Hashtable was only a temporary index to assist in building of the tree).