daemon mode not quite working

Discussion in 'C++' started by unknown@example.com, Apr 30, 2008.

  1. Guest

    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
    --
    weeks of software enineering safe hours of planing ;)
     
    , Apr 30, 2008
    #1
    1. Advertising

  2. sk_usenet Guest

    <> wrote in message
    > 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?

    --
    http://techytalk.googlepages.com
     
    sk_usenet, Apr 30, 2008
    #2
    1. Advertising

  3. sk_usenet Guest

    "Victor Bazarov" <> wrote in message >
    wrote:
    [snip OT]

    > 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.

    --
    http://techytalk.googlepages.com
     
    sk_usenet, Apr 30, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    501
    Andy Dingley
    Dec 27, 2003
  2. J. W. McCall
    Replies:
    3
    Views:
    378
    Bengt Richter
    Aug 6, 2003
  3. Jean-Paul Calderone
    Replies:
    0
    Views:
    471
    Jean-Paul Calderone
    Mar 20, 2009
  4. Floris Bruynooghe
    Replies:
    1
    Views:
    465
    Floris Bruynooghe
    Mar 24, 2009
  5. Daemon Win32::Daemon;

    , Sep 7, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    268
Loading...

Share This Page