C in Linux Kernel Code to List PID, Name, and Status

Download Solution: Click to Download Solution
Solution File Name: CLinuxKernelCodeListPIDNameStatus.docx
Unzip Password: prestobear.com

Problem:
This is C in Linux Kernel Code to list out the PID, name, and state of current processes


1.partonelist.c
#include < linux/init.h >
#include < linux/kernel.h >
#include < linux/module.h >
#include < linux/sched.h >

int partone_linear_list_init(void) {

}

void partone_linear_list_exit(void) {
  printk(KERN_INFO "Module removed.\n");
}

module_init(partone_linear_list_init);
module_exit(partone_linear_list_exit);

2.Makefile
obj-m += partonelist.o

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

all:
	$(MAKE) -C $(KERNELDIR) M=$(PWD)
clean:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) clean

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.