Skip to content

Instantly share code, notes, and snippets.

@epcnt19
Created April 1, 2019 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epcnt19/aa809ee865d4076b032987cb9116e479 to your computer and use it in GitHub Desktop.
Save epcnt19/aa809ee865d4076b032987cb9116e479 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<sys/syscall.h>
#include<sys/stat.h>
#define GETCWD 79
#define MKDIR 83
#define RMDIR 84
#define CHMOD 90
#define REGIST_PID 340
#define UNREGIST_PID 341
#define REGIST_SYSCALL_NUM 342
#define UNREGIST_SYSCALL_NUM 343
void regist_pid(int pid){
syscall(REGIST_PID,pid);
}
void unregist_pid(int pid){
syscall(UNREGIST_PID,pid);
}
void regist_syscall_num(int syscall_num){
syscall(REGIST_SYSCALL_NUM,syscall_num);
}
void unregist_syscall_num(int syscall_num){
syscall(UNREGIST_SYSCALL_NUM,syscall_num);
}
int main(int arc,char *argv[]){
int pid;
pid = fork();
if(pid > 0){
//parent
printf("parent : child pid -> %d\n",pid);
regist_pid(pid);
regist_syscall_num(MKDIR);
}else if(pid == 0){
//child
sleep(1);
mkdir("helloworld",0777);
_exit(-1);
}else{
perror("fork");
}
wait(NULL);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment