Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm in the process of writing a simple C-based daemon mostly for the learning experience. At this point, I've got a working daemon and I'd like to expose some configuration options to users.

What's the standard way that most daemons provide configuration options and are there any good C libraries that help with this?

share|improve this question
Should be moved to stackoverflow. – user606723 Aug 5 '11 at 15:19
I'm not sure if this should be moved to StackOverflow. What configuration options are considered standard varies from OS to OS. Presumably, by posting here, the OP is seeking an Ubuntu perspective. – Eliah Kagan May 14 '12 at 17:45
up vote 3 down vote accepted

It really depends on how complicated you want to get.

Two options main options.

  1. Accept command-line options. For a standard daemon, these would be put into the init.d script for system configuration.
  2. Your own conf file inside of /etc/yourDaemon. In this case, there is typically a command-line option to specify the location of the configuration file, and would, by default, be put in /etc/yourDaemon/blah.conf

I recommend libconfuse.

share|improve this answer


GSettings is as close as there is to a standard way for storing configuration. It uses dconf as a backend.

The advantages of using GSettings and dconf include:

  • Users can use the prebuilt dconf-editor tool to modify the configuration. Many applications also provide a preferences program to provide a higher level interface to this.

  • Consistency - your settings are stored in the same place as the settings for most of the GNOME desktop. This makes administrative jobs such as backup easier because the user doesn't have to remember the location of your config file.

  • Speed - dconf is optimised for speed, especially in read operations which are the most common.

share|improve this answer
This is a good API for application settings. The settings are done on a per-user level. Obviously not suitable for a daemon. gnome's own description of GSettings - "High-level API for application settings" – user606723 Aug 5 '11 at 17:24
The distinction between applications and daemons is artificial. Both are types of programs - daemons just run in the background. So it is not obvious that GSettings in unsuitable for a daemon. Yes the settings are per-user but why is this wrong for a daemon? Daemons often are per user eg. gnome-settings-daemon, zeitgeist-daemon, ubuntuone-syncdaemon ... I can't find any reason why you shouldn't use an application settings framework for daemon settings. – dv3500ea Aug 6 '11 at 10:07
Because a classic daemon is -not- per user. And because neither you or the asker made any such distinction. – user606723 Aug 6 '11 at 15:02
Well I don't know what you mean by classic daemon. A daemon as I understand it is any background process and there are some standard steps to set one up. A daemon can be either system wide or user specific. GSettings is normally used per user but AFAIK it can be used system wide just like gconf. – dv3500ea Aug 6 '11 at 16:22
There are also classes of user applications that could qualify. NetworkManager comes to mind - even though it has an user interface. – Stephen Eilert Jan 31 '12 at 19:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.