#define _DEFAULT_SOURCE // 加上这个宏定义
//#define _BSD_SOURCE // 如果是比较老的内核的话则用这个宏定义
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
int main(int argc, char **argv) {
int32_t loopcount = 0;
if (daemon(1, 1) != 0) {
perror("deamon error");
return -1;
}
while (1) {
fprintf(stdout, "index %d\n", ++loopcount);
sleep(2);
}
return 0;
}
Linux C/C++ 找不到daemon函数声明的解决方法
于 2017-10-23 11:45:19 首次发布