Linux C/C++ 找不到deamon函数声明的解决方法

来源:互联网 发布:三菱plc编程手册 微盘 编辑:程序博客网 时间:2024/05/14 18:19
#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;}