daemon mode not quite working

U

unknown

Hi,

I have an application featuring a verbose mode and a daemon mode.
It's working just fine in verbose mode but in daemon mode it doesn't quite
seem to be functioning properly,
I get into Daemon mode with a fork command followed by exit() to be
specific, it looks like:
[C++]
pid = fork();
if (pid < 0)
{
exit(EXIT_FAILURE);
}
else if (pid > 0)
{
exit(EXIT_SUCCESS);
}

umask(0);

sid = setsid();
[/C++]
Is there a problem with this? Do I miss anything?
Thanks,
Ron
 
S

sk_usenet

Hi,

I have an application featuring a verbose mode and a daemon mode.
It's working just fine in verbose mode but in daemon mode it doesn't quite
seem to be functioning properly,
I get into Daemon mode with a fork command followed by exit() to be
specific, it looks like:
[C++]
pid = fork();
if (pid < 0)
{
exit(EXIT_FAILURE);
}
else if (pid > 0)
{
exit(EXIT_SUCCESS);
}

umask(0);

sid = setsid();
[/C++]
Is there a problem with this? Do I miss anything?

1. Nothing C++ language specific here, so it's OT.
2. Post to comp.unix.programmer. Also post as to what you mean by not
functioning properly. Have you tried some tool like ktrace/strace to debug
the problem?
 
S

sk_usenet

The problem is that you're posting in a wrong newsgroup. C++ does
not define how "fork" or "umask" or "setsid" works. You need to
post your inquiry in the newsgroup that deals with your OS. You

You are very correct in marking the question as OT.
probably missed the fact that this newsgroup only discusses the
language issues, not interprocess communication provided by your
platform. Sorry.

I didn't see any part referring to IPC etc. He is just trying to dameonize a
process, and it's pretty standard set of rules in Unix. Well, of course it's
still OT.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,828
Latest member
LauraCastr

Latest Threads

Top