processes
This commit is contained in:
parent
bbedbefe62
commit
573887adce
@ -0,0 +1,16 @@
|
||||
#include "processes.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void list_processes(FILE *output) {
|
||||
FILE *fp = popen("ps -eo pid,comm --sort=pid", "r");
|
||||
if (fp == NULL) {
|
||||
fprintf(output, "Error opening process list\n");
|
||||
return;
|
||||
}
|
||||
char line[256];
|
||||
while (fgets(line, sizeof(line), fp) != NULL) {
|
||||
fprintf(output, "%s", line);
|
||||
}
|
||||
pclose(fp);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
#ifndef PROCESSES_H
|
||||
#define PROCESSES_H
|
||||
#include <stdio.h>
|
||||
void list_processes(FILE *output);
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user