int main(int arg, char *args[]) { if (arg < 2)//如果没有参数,main函数返回 { printf("usage:qqserverd port\n"); return -1; } int iport = atoi(args[1]); if (iport == 0) { printf("port %d is invalid\n", iport); return -1; } setdaemon();//进入daemon状态 work w(iport); printf("qqserver is begin\n"); signal1(SIGINT, catch_Signal); signal1(SIGPIPE, catch_Signal); w.run(); printf("qqserver is end\n"); return 0; }
int main(void) { setdaemon(); mysingal(SIGINT,catch_singal); mysingal(SIGPIPE,catch_singal); while(1){ puts("Hello\n"); sleep(1); } return EXIT_SUCCESS; }
int main(void) { setdaemon(); //把进程设置成daemon状态 signal1(SIGINT,catch_Signal);//捕捉Signal 信号 signal1(SIGPIPE,catch_Signal);//捕捉Signal 信号 while(1) { puts("hello world"); sleep(1); } return EXIT_SUCCESS; }
int main(int arg,char *args[]) { setdaemon(); char buf[100]; int i = 0; while(1) { memset(buf,0,sizeof(buf)); sprintf(buf,"log %d",i++); writelog(buf); sleep(1); } }