-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1bcaa4
commit 275e044
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
LOCAL_PATH := $(call my-dir) | ||
|
||
include $(CLEAR_VARS) | ||
LOCAL_SRC_FILES := daemon.c | ||
LOCAL_MODULE := daemon | ||
LOCAL_CFLAGS += -pie -fPIE | ||
LOCAL_LDFLAGS += -pie -fPIE | ||
LOCAL_FORCE_STATIC_EXECUTABLE := true | ||
include $(BUILD_EXECUTABLE) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*this program create a daemon process, | ||
which will make OOM_killer awaken periodically for some pre-set period T | ||
*/ | ||
#include <unistd.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <signal.h> | ||
#define T 2 | ||
|
||
|
||
int main(void) | ||
{ | ||
if(daemon(0,0) == -1) | ||
{ | ||
printf("fail to create daemon process\n"); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
while(1) | ||
{ | ||
//use system call 384, which is oom_killer to check | ||
//if a user has run out its memory quota. | ||
//If that, then it will kill the process that has the highest RSS | ||
//among all processes belonging to the user. | ||
//syscall(383,10070,100000000); | ||
syscall(378); | ||
sleep(T); | ||
} | ||
return 0; | ||
} |