Created
March 18, 2018 12:04
-
-
Save virusdefender/f494feb00f039bf6b97b49acbd29f564 to your computer and use it in GitHub Desktop.
reset_proc_memory.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/time.h> | |
#include <sys/resource.h> | |
#include <stdio.h> | |
int main(){ | |
struct rusage usage; | |
while (1) { | |
getrusage(RUSAGE_SELF, &usage); | |
printf("%lld\n", usage.ru_maxrss); | |
fflush(NULL); | |
sleep(5); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj-m += reset_proc_memory.o | |
KDIR ?= /lib/modules/$(shell uname -r)/build | |
all: | |
make -C $(KDIR) M=$(PWD) modules | |
clean: | |
make -C $(KDIR) M=$(PWD) clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/module.h> | |
#include <linux/kernel.h> | |
#include <linux/sched/signal.h> | |
void reset(void) | |
{ | |
struct task_struct* task; | |
for_each_process(task) { | |
// TODO lock | |
task->signal->cmaxrss = 0; | |
task->signal->maxrss = 0; | |
} | |
} | |
int init_module(void) | |
{ | |
reset(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment