LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Algorithm to Determine if Using Initd Or Systemd (https://www.linuxquestions.org/questions/linux-general-1/algorithm-to-determine-if-using-initd-or-systemd-4175428391/)

Brandon9000 09-21-2012 10:24 AM

Algorithm to Determine if Using Initd Or Systemd
 
How can I (actually how can a program of mine) determine if the system it wakes up on is interacting with services via initd or systemd? I have a program which has to be able to interact with services in both environments.

Thank you in advance for any light you can shed on this.

sundialsvcs 09-21-2012 10:28 AM

You could probably see which file exists ...

But, application programs don't interact directly with either of these processes, and those programs that do ought not care how the services that they require are being rendered to them.

You really want to design your program so that it is agnostic to these issues. If you do for example have a dependency in the installation process, then you should first detect what you think to be the case, then stop and ask the installing user to confirm your assessment and if need be to overrule it.

Furthermore, when your program is in service, it should continuously do some kind of "stink test" to recognize when it is in a potentially-damaging situation where it concludes that, "the configuration option that I was given just can't be right ... or maybe it's no longer right." (The user could, after all, switch his system from one to the other without telling you, and you surely don't want yours to be the piece-of-software that just got egg-faced in some sysadmin forum somewhere!)

For programs like these, a good strategy is:
  • "I think I know the answer, but ..."
  • "... I'm going to oblige you to tell me one way or the other, and ..."
  • "... I still won't quite believe you, nor trust that what you said will always remain true."

Brandon9000 09-21-2012 10:43 AM

It's not an installation issue. My program determines various information about services and sends it back to a control center via the Internet. If the environment is using systemd, and my program thinks it's using initd, it will report false information. I need an algorithm to know which system is in use.


All times are GMT -5. The time now is 05:12 PM.