Reputation: 16029
I am using C language and Linux as my programming platform.
I am developing a user-space application that runs in a background, like a daemon. And my problem is, I want another user-space application to communicate with this daemon.
I know that I have to use Interprocess Communication method but I don't know what is the correct implementation.
But using IPC in my communication implementation is my other option. Actually I just want to change the attribute of my daemon by using another application. Please see below a senario:
My first option is by accessing a file with the values of the properties. So that my deamon will poll that values. While the other application will change that values.
I am not sure the efficiency of my options. Please advice.
THanks.
Upvotes: 5
Views: 1132
Reputation: 36
I'd make the daemon listen on a pipe/fifo if it's simple enough that you only need to read a couple of bytes fed in from another program. Otherwise a local domain socket is nice to run a simple protocol over.
Upvotes: 1
Reputation: 61016
Updating the config file and sending a signal to cause re-read is a standard practise, cheap and easy.
Upvotes: 4
Reputation: 15221
If I were you, I'd forego IPC completely and instead have the daemon monitor a config file for changes. IPC is only really needed if you're going to be sending thousands of messages per second and the overhead would get intolerable.
inotify is an option for file monitoring.
Upvotes: 2
Reputation: 798566
You're looking for D-Bus. Store the initial values in a file, then listen over D-Bus for requests to change it.
Upvotes: 3