Экспериментурую со своим самописным сетевым демоном. Организовал запуск демона средствами процесса init, в /etc/inittab добавил запись:
d:345:respawn:/path/to/my/daemon -d
Периодически в логи сыпятся сообщения:
Id "d" respawning too fast: disabled for 5 minutes
Как я догадываюсь, что-то не так с моим приложением

Вот как я создаю демона:
Код
/* closeall() - close all FDs >= specified value */
void closeall(int fd)
{
int fdlimit = sysconf(_SC_OPEN_MAX);
while ( fd < fdlimit )
close(fd++);
}
/* daemon() - detach process from user and disappear into the background */
int daemon(int nochdir, int noclose)
{
switch ( fork() )
{
case 0:
break;
case -1:
return -1;
default:
exit(0); /* exit the original process */
}
/* create new session not having controlling terminal */
if (setsid() < 0) /* shoudn't fail */
return -1;
/* now we aren't session group leader, so never gain controlling terminal */
switch ( fork() )
{
case 0:
break;
case -1:
return -1;
default:
exit(0);
}
/* here run the child */
if ( !nochdir )
chdir("/");
if ( !noclose ) {
closeall(0);
open("/dev/null", O_RDWR);
dup(0); dup(0);
}
return 0;
}
...
int main(void)
{
.....
if ( daemon(0, 0) < 0 ) {
perror("daemon");
exit(2);
}
process(); /* run main process */
return 0;
}
void closeall(int fd)
{
int fdlimit = sysconf(_SC_OPEN_MAX);
while ( fd < fdlimit )
close(fd++);
}
/* daemon() - detach process from user and disappear into the background */
int daemon(int nochdir, int noclose)
{
switch ( fork() )
{
case 0:
break;
case -1:
return -1;
default:
exit(0); /* exit the original process */
}
/* create new session not having controlling terminal */
if (setsid() < 0) /* shoudn't fail */
return -1;
/* now we aren't session group leader, so never gain controlling terminal */
switch ( fork() )
{
case 0:
break;
case -1:
return -1;
default:
exit(0);
}
/* here run the child */
if ( !nochdir )
chdir("/");
if ( !noclose ) {
closeall(0);
open("/dev/null", O_RDWR);
dup(0); dup(0);
}
return 0;
}
...
int main(void)
{
.....
if ( daemon(0, 0) < 0 ) {
perror("daemon");
exit(2);
}
process(); /* run main process */
return 0;
}
На что стоит еще обратить внимание?
Спасибо.