Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12244

Making a kernel module that can return a list of currently running processes to the user space through a character device? [closed]

$
0
0

I'm trying to create a kernel module that will create a /dev/process_list character device. If a read() call is made on my character device, the kernel module must return information on all currently running processes, namely: their process ID, their parents PID, which CPU it's running on, and the current state of the process.

Currently, my idea for the user space code is as follows:

#include <stdio.h>#include <errno.h>int main(){     char* buffer = (char*) malloc(sizeof(char*));     FILE* fd;     fd = open("/dev/process_list", O_RDONLY);     if(!fd){          printf("Failure\n");          exit(EXIT_FAILURE);     }     while( /*no more inputs being read in*/ ){               char bytes_read = read(fd, buffer, buffer_length);     }     close(fd);     return 0;}

However, I'm new to kernel modules and unsure of how to make this. How can I do it?


Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>