49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
#pragma once
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <dirent.h>
|
|
#include <ctype.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include "../data_structure/list_entry.h"
|
|
|
|
#define THREAD_MON_PROC_DIR "/proc"
|
|
#define MAX_PROC 32768
|
|
#define MAX_NAME 256
|
|
#define MAX_ARRAY 65536
|
|
|
|
typedef struct _process_list {
|
|
LIST_ENTRY entry;
|
|
int pid;
|
|
} process_list, *pprocess_list;
|
|
|
|
/**
|
|
* Get all child processes of the given PID.
|
|
* Returns a flat linked list (pprocess_list).
|
|
* The head node's pid is -1, used only as the list entry.
|
|
* Memory allocated for nodes must be freed using FreeProcessOrThreadList().
|
|
*/
|
|
pprocess_list GetProcessListByPID(int pid);
|
|
|
|
/**
|
|
* Get all threads (tasks) of the given PID.
|
|
* Returns a flat linked list.
|
|
* The head node's pid is -1, used only as the list entry.
|
|
* Memory allocated for nodes must be freed using FreeProcessOrThreadList().
|
|
*/
|
|
pprocess_list GetThreadListByPID(int pid);
|
|
|
|
/**
|
|
* Get all threads and child processes of the given PID recursively.
|
|
* Returns a flat linked list.
|
|
* The head node's pid is -1, used only as the list entry.
|
|
* Memory allocated for nodes must be freed using FreeProcessOrThreadList().
|
|
*/
|
|
pprocess_list GetAllProcessAndThreadByPID(int pid);
|
|
|
|
/**
|
|
* Free the linked list returned by the above functions, including all nodes.
|
|
*/
|
|
void FreeProcessOrThreadList(pprocess_list list); |