int daemon (int __nochdir,int __noclose);
如果__nochdir的值为0,则将切换工作目录为根目录
如果__noclose为0,则将标准输入,输出和标准错误都重定向到/dev/null经过这个函数
|
#include <unistd.h> #include <stdio.h> int do_sth() { //Add what u want
return 0; } int main() { daemon(0,0); while ( 1 ) { do_sth(); sleep(1); } }
|
阅读(626) | 评论(0) | 转发(0) |