Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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 want to write a service in C.

While this service is running in background and processing some information I need to grab the results from this service from other applications or from command line.

Background: I need a C application/service due to performance issues. The UI will be implemented in a higher language like Java or C#/Mono on Linux. The C application will basically process data, which will come in from another source. The UI layer should be able to grab the results in a loop every few milliseconds for example and display it to the user. Also it should be possible to pause/start/configure the service from the Java application. Thats where the question begins.

How do I implement the service in C, so that it can respond to commands in runtime?

Thanks, Eduard

share|improve this question
This is very generic and not at all Unix/Linux specific. In general you implement it the same way you would, for instance, in Java. However, in plain C the objects will be only in your naming conventions and the libraries are used a little differently. – Bananguin Dec 15 '12 at 15:08
up vote 2 down vote accepted

If you want to separate a service and its UI, you need some kind of IPC mechanism to make them communicate. Several of these exist, but the standard on linux-based systems these days is D-Bus, which can be used to access a service written in C from a client written in any language that has D-Bus bindings (Java and Mono have them). Your service should provide a D-Bus service for the client to call. D-Bus also provides a way to autostart services. Stopping and configuring can easily be implemented.

I would not make your UI grab results every few milliseconds as humans can't process info that quickly. An update rate of 25-30 times per second should be more than enough.

share|improve this answer
Not to denigrate your answer (which is extremely clear and useful) but most humans I know can't even handle update at a "mere" 30 times per second. – Isaac Rabinovitch Dec 15 '12 at 21:37
That depends on how it's presented. I was assuming an awful lot and guessing that it would be some sort of graphical display that would still work when watching it as a movie, such as audio visualizations or simply moving graphs of whatever metrics that moove relatively smoothly. – Dennis Kaarsemaker Dec 15 '12 at 21:40
Sounds like the answer I was looking for. Thanks! – Eduard Dec 15 '12 at 21:49

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.