Mac OSX Launch Daemon

I have developed a dummy Launch Daemon for Mac OSX that keeps writing something to the console(syslog) every 5 minutes. Now, I want to write an application that can communicate with this service. By communicating I mean that the user should be able to input the logging frequency(time). For eg, if the service is logging 'Hello world' every 5 minutes, the user should be able to change it to something else (say 2 mins) and the change should be reflected. Any idea on how I should proceed for developing the application and facilitate interprocess communication between the daemon and the application? Thanks.
This is one (of many) possible ways:
Write the dummy daemon to read the update interval from a config file as part of its initialisation.
Say, /etc/my_dummy_damon/my_dummy_damon.rc
Put in a SIGHUP handler which reinitialises the daemon (it reads the config file again).

Write a small command-line utility which updates the config file and then sends a SIGHUP signal to the daemon process.

SIGHUP
The SIGHUP signal is sent to a process when its controlling terminal is closed. It was originally designed to notify the process of a serial line drop (a hangup). In modern systems, this signal usually means that the controlling pseudo or virtual terminal has been closed. Many daemons will reload their configuration files and reopen their logfiles instead of exiting when receiving this signal.
https://en.wikipedia.org/wiki/SIGHUP#POSIX_signals
Hi JLBorges! Thanks for your guidance.

But I have a question- In Mac OS, isn't the plist already a config file. I have written a plist file which is stored in the /Library/LaunchDaemons folder and is parsed on system startup. So that means, I would have to make the change in the plist file you mean?
The property list file can be used to store the configuration information for the daemon.

Something like:
1
2
<key>Update Interval</key>
<integer>5</integer>


Ok, so I mananged to create an IPC between the service and the application. So I am getting the user's input through the named pipe, however, now I am stuck with how do I reflect this change in the plist? I can't find any way through which I can change the 'Update interval' key in the plist or even access it. Any suggestions?
Last edited on
But I am looking to do this through C++ not Objective-c. I can't seem to find any equivalent functions in C++ to parse the plist and edit it.
One option is to use Objective-C++ (makes Objective-C code usable from C++).

Another is to modify the xml file (the property list file) using the C++ input output library. (Read lines into a vector of strings, modify the string containing the update interval, overwrite the file with the new contents.)

A third option is to use an XML parser. For instance TinyXML: http://www.grinninglizard.com/tinyxml/
Topic archived. No new replies allowed.