📄 util.cpp
字号:
#include <sys/time.h>#include <sys/ipc.h>#include <sys/msg.h>#include <sys/wait.h>#include "util.h"int loadmodule (char *module){ pid_t pid; char *my_argv[4] = {INSMOD_PROG, module, NULL}; char *my_envp[1] = {NULL}; int status; if ((pid = vfork()) == 0) { //this is the child do the execve execve (INSMOD_PATH""INSMOD_PROG, my_argv, my_envp); _exit (1); } else { // this is the parent. pid = waitpid (pid, &status, 0); if (WIFEXITED (status) && (WEXITSTATUS (status) != 0)) { return 1; } else if (WIFEXITED (status) && (WEXITSTATUS (status) == 0)) { return 0; } else { printf ("Seems that an error happened during module loading\n"); return 1; } } return 0;}int gettime_ms (void){ struct timeval tv1; struct timezone tz; gettimeofday (&tv1, &tz); return tv1.tv_sec * 1000 + tv1.tv_usec/1000;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -