* catch exit status of daemon
@ 2015-01-06 15:22 Yash Jain
2015-01-06 15:35 ` nick
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Yash Jain @ 2015-01-06 15:22 UTC (permalink / raw)
To: kernelnewbies
Hello All,
I have one dumb question,
I wanted to write a process which monitors the exit status of the daemon,
The Main process would fork a service, which would internally fork a child
and , exit from the process. If main process wants to query the status of
the daemon, how it can be achived.
For ex :
Process A would call a syslog service, which would internally fork a child,
daemon it and exit, so if process A wants to wait for the syslog process,
is it possible.
Thanks in advance
Regards,
Yash.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150106/030619af/attachment.html
^ permalink raw reply [flat|nested] 8+ messages in thread* catch exit status of daemon 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 2 siblings, 0 replies; 8+ messages in thread From: nick @ 2015-01-06 15:35 UTC (permalink / raw) To: kernelnewbies Yash, There are two ways to do this either use the signals API or IPC(inter-process communication) libraries. I don't known the functions off the top of my head but this can get you started. Nick On 2015-01-06 10:22 AM, Yash Jain wrote: > Hello All, > I have one dumb question, > I wanted to write a process which monitors the exit status of the daemon, > > The Main process would fork a service, which would internally fork a child > and , exit from the process. If main process wants to query the status of > the daemon, how it can be achived. > > For ex : > Process A would call a syslog service, which would internally fork a child, > daemon it and exit, so if process A wants to wait for the syslog process, > is it possible. > > Thanks in advance > > Regards, > Yash. > > > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > ^ permalink raw reply [flat|nested] 8+ messages in thread
* catch exit status of daemon 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 2 siblings, 0 replies; 8+ messages in thread From: Valdis.Kletnieks at vt.edu @ 2015-01-06 16:24 UTC (permalink / raw) To: kernelnewbies On Tue, 06 Jan 2015 20:52:02 +0530, Yash Jain said: > Process A would call a syslog service, which would internally fork a child, > daemon it and exit, so if process A wants to wait for the syslog process, > is it possible. % man 2 wait -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 848 bytes Desc: not available Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150106/843a0233/attachment-0001.bin ^ permalink raw reply [flat|nested] 8+ messages in thread
* catch exit status of daemon 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 2 siblings, 1 reply; 8+ messages in thread From: Anuz Pratap Singh Tomar @ 2015-01-06 16:46 UTC (permalink / raw) To: kernelnewbies On Tue, Jan 6, 2015 at 3:22 PM, Yash Jain <yash2learn@gmail.com> wrote: > Hello All, > I have one dumb question, > I wanted to write a process which monitors the exit status of the daemon, > > The Main process would fork a service, which would internally fork a child > and , exit from the process. If main process wants to query the status of > the daemon, how it can be achived. > > For ex : > Process A would call a syslog service, which would internally fork a > child, daemon it and exit, so if process A wants to wait for the syslog > process, is it possible. > > waitpid() signal() > Thanks in advance > > Regards, > Yash. > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > -- Thank you Warm Regards Anuz -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150106/fa93c11c/attachment.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* catch exit status of daemon 2015-01-06 16:46 ` Anuz Pratap Singh Tomar @ 2015-01-06 19:27 ` Nizam Haider 2015-01-07 8:05 ` Sudip Mukherjee 0 siblings, 1 reply; 8+ messages in thread From: Nizam Haider @ 2015-01-06 19:27 UTC (permalink / raw) To: kernelnewbies Anuz Pratap Singh Tomar <chambilkethakur <at> gmail.com> writes: > > > > On Tue, Jan 6, 2015 at 3:22 PM, Yash Jain <yash2learn <at> gmail.com> wrote:Hello All,I have one dumb question, > I wanted to write a process which monitors the exit status of the daemon, > > The Main process would fork a service, which would internally fork a child and , exit from the process. If main process wants to query the status of the daemon, how it can be achived. > > For ex : > Process A would call a syslog service, which would internally fork a child, daemon it and exit, so if process A wants to wait for the syslog process, is it possible. > > > waitpid() > > signal() WIFEXITED WEXITSTATUS > > > > Thanks in advance > > Regards, > Yash. > > _______________________________________________ > Kernelnewbies mailing listKernelnewbies <at> kernelnewbies.orghttp://lists.kernelnewbies.org/mailman/listinfo/kernelnewbi es > > > -- Thank you Warm RegardsAnuz > > > > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies <at> kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > ^ permalink raw reply [flat|nested] 8+ messages in thread
* catch exit status of daemon 2015-01-06 19:27 ` Nizam Haider @ 2015-01-07 8:05 ` Sudip Mukherjee 2015-01-07 9:10 ` Yash Jain 0 siblings, 1 reply; 8+ messages in thread From: Sudip Mukherjee @ 2015-01-07 8:05 UTC (permalink / raw) To: kernelnewbies On Wed, Jan 7, 2015 at 12:57 AM, Nizam Haider <nizamhaider786@gmail.com> wrote: > Anuz Pratap Singh Tomar <chambilkethakur <at> gmail.com> writes: > >> >> >> >> On Tue, Jan 6, 2015 at 3:22 PM, Yash Jain <yash2learn <at> gmail.com> > wrote:Hello All,I have one dumb question, >> I wanted to write a process which monitors the exit status of the daemon, >> >> The Main process would fork a service, which would internally fork a child > and , exit from the process. If main process wants to query the status of > the daemon, how it can be achived. >> >> For ex : >> Process A would call a syslog service, which would internally fork a > child, daemon it and exit, so if process A wants to wait for the syslog > process, is it possible. >> >> >> waitpid() >> >> signal() > WIFEXITED > WEXITSTATUS doubt -- wait and waitpid will be for the parent process to wait for its child. but for a daemon the parent is init . so the exit status should be sent to init and not to his process. then how does he get the exit status sudip >> ^ permalink raw reply [flat|nested] 8+ messages in thread
* catch exit status of daemon 2015-01-07 8:05 ` Sudip Mukherjee @ 2015-01-07 9:10 ` Yash Jain 2015-01-07 22:58 ` Bernd Petrovitsch 0 siblings, 1 reply; 8+ messages in thread From: Yash Jain @ 2015-01-07 9:10 UTC (permalink / raw) To: kernelnewbies 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, 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. IPC is not an option for me, because there are several service and process A do not know how and what is the process C, it should just monitor so many child process. Regards, Yash. On Wed, Jan 7, 2015 at 1:35 PM, Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote: > On Wed, Jan 7, 2015 at 12:57 AM, Nizam Haider <nizamhaider786@gmail.com> > wrote: > > Anuz Pratap Singh Tomar <chambilkethakur <at> gmail.com> writes: > > > >> > >> > >> > >> On Tue, Jan 6, 2015 at 3:22 PM, Yash Jain <yash2learn <at> gmail.com> > > wrote:Hello All,I have one dumb question, > >> I wanted to write a process which monitors the exit status of the > daemon, > >> > >> The Main process would fork a service, which would internally fork a > child > > and , exit from the process. If main process wants to query the status of > > the daemon, how it can be achived. > >> > >> For ex : > >> Process A would call a syslog service, which would internally fork a > > child, daemon it and exit, so if process A wants to wait for the syslog > > process, is it possible. > >> > >> > >> waitpid() > >> > >> signal() > > WIFEXITED > > WEXITSTATUS > > doubt -- > wait and waitpid will be for the parent process to wait for its child. > but for a daemon the parent is init . > so the exit status should be sent to init and not to his process. then > how does he get the exit status > > sudip > > >> > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150107/1580a91c/attachment.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* catch exit status of daemon 2015-01-07 9:10 ` Yash Jain @ 2015-01-07 22:58 ` Bernd Petrovitsch 0 siblings, 0 replies; 8+ messages in thread From: Bernd Petrovitsch @ 2015-01-07 22:58 UTC (permalink / raw) To: kernelnewbies 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-01-07 22:58 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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).