Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
440 views
in Technique[技术] by (71.8m points)

c - How to design a single background process that can be called multiple times independently?

I am writing for generic linux/unix systems and have an unusual use case for which the design of the program is not clear to me.

(FYI: for those not familiar with the unix mentality, sometimes called the Unix Philosophy, the idea is to provide functionality by making lots of small programs that run independently, rather than making large conglomerate applications.)

So, in my case I want an application that will provide alerts. The application would be run from the command line with parameters defining the characteristics of the alert, then it would put itself into the background and wake up when the alert needs to be issued.

The problem is when a second alert is created. Rather than create a second process, I would like the application to notify the existing background process of the new alert and add it to its list of alerts. That way I have only a single "alert" process at any given time. One advantage of this is that since only one process controls all the alerts, it can list them. For example, the user might give a command like "alert list" and alert(2) will notify the existing alert process of the request and exit, then the existing process will print out all the alerts that are pending, then go into the background again.

What is the right way to do this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.6k users

...