kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: bernd@petrovitsch.priv.at (Bernd Petrovitsch)
To: kernelnewbies@lists.kernelnewbies.org
Subject: catch exit status of daemon
Date: Wed, 07 Jan 2015 23:58:47 +0100	[thread overview]
Message-ID: <1420671534.3099.95.camel@thorin> (raw)
In-Reply-To: <CAJnayPAoHvQfT6+prJiaT4Zt_q70v0eNpTZU2ojQAh6PEatbEg@mail.gmail.com>

On Mit, 2015-01-07 at 14:40 +0530, Yash Jain wrote:
> wait and waitpid would not work because a Process A would wait for process
> B(which is a parent of the daemon), process B immediately exits and process
> A would be notified.
> In my case, I want to query the status of process C(which is child of

> process B) / grandchild of process A which is a child of init after process
> B terminates,

And exactly here ends the usual Unix story because when "Process C" is a
child of `init` (or whatever process has pid 1), "Process A" shouldn't
receive a SIGCLD (because that is delivered only to it's parent process
and one of the main purposes of daemonizing "Process C" is to get to
into that position;-).

>                   fork                            fork
> process A -------------> Process B --------------> Process C
> 
> Process A should query the status of process C
> 
> Once process C is daemon, Process C would be the the child of init.
> 
> Can we do something by making a process A to be a daemon (child of init),
> because process A and process C are sibling, can siblings query the status
> of each other.

Not with the usual model as outlined above.

The short term solution are
- to implement it in the daemons/program/applications.
- to start the daemon in some "debug mode" so that it doesn't daemonize
  itself.
- (if you can't that or won't fix the daemon) to hack init so that when
  some PID terminates, it notifies the other process.

There were patches on LKML so that any process can choose to inherit
daemonized processes forked by (it's own;-) child processes (instead of
'init' - the main reason being the typical desktop manager (kdn, gdm,
xdm, ....) process which also may want to do that) but I don't know the
state of them ....

[ crap deleted ]

Kind regards,
	Bernd
-- 
"I dislike type abstraction if it has no real reason. And saving
on typing is not a good reason - if your typing speed is the main
issue when you're coding, you're doing something seriously wrong."
    - Linus Torvalds

      reply	other threads:[~2015-01-07 22:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-06 15:22 catch exit status of daemon Yash Jain
2015-01-06 15:35 ` nick
2015-01-06 16:24 ` Valdis.Kletnieks at vt.edu
2015-01-06 16:46 ` Anuz Pratap Singh Tomar
2015-01-06 19:27   ` Nizam Haider
2015-01-07  8:05     ` Sudip Mukherjee
2015-01-07  9:10       ` Yash Jain
2015-01-07 22:58         ` Bernd Petrovitsch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420671534.3099.95.camel@thorin \
    --to=bernd@petrovitsch.priv.at \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).