当前位置: 技术问答>linux和unix
daemon进程crash了怎么才能把错误信息记录下来?
来源: 互联网 发布时间:2016-03-29
本文导语: 是不是只能执行完以后查看进程中是否有它才能知道此daemon进程有没有启动成功? 如下: #include #define MAXFD 64 void daemon_init() { int i; pid_t pid; if ( (pid = fork()) != 0) exit(0); /* parent terminates */ sets...
是不是只能执行完以后查看进程中是否有它才能知道此daemon进程有没有启动成功?
如下:
#include
#define MAXFD 64
void daemon_init()
{
int i;
pid_t pid;
if ( (pid = fork()) != 0)
exit(0); /* parent terminates */
setsid(); /* become session leader */
signal(SIGHUP, SIG_IGN);
if ( (pid = fork()) != 0)
exit(0); /* 1st child terminates */
chdir("/"); /* change working directory */
umask(0); /* clear our file mode creation mask */
for (i = 0; i
如下:
#include
#define MAXFD 64
void daemon_init()
{
int i;
pid_t pid;
if ( (pid = fork()) != 0)
exit(0); /* parent terminates */
setsid(); /* become session leader */
signal(SIGHUP, SIG_IGN);
if ( (pid = fork()) != 0)
exit(0); /* 1st child terminates */
chdir("/"); /* change working directory */
umask(0); /* clear our file mode creation mask */
for (i = 0; i