c语言怎么在后台挂起进程

MAXFILE = 65535

// 创建deamon进程
pc = fork(); //第一步
if(pc<0)
{
input_log("创建dameon进程失败");
exit(1);
}
else if(pc>0)
exit(0);
setsid(); //第二步
chdir("/"); //第三步
umask(0); //第四步
for(i=0;i<MAXFILE;i++) //第五步
close(i);

posted @ 2015-02-03 14:21  liuyawei  阅读(812)  评论(0编辑  收藏  举报