Skip to content
Advertisement

Writing a background program with command line interaction [closed]

I’m just playing around and want to write a c++ program that monitors my CPU temperature, (i know there is no need to do it, i know i can get that info without writing a program). I’m willing to design the whole thing as a background process in linux and be able to communicate with it via command line.

let’s say my program name is: cputemp

i want to be able to run the command cputemp -temp and get the temp values.

I’ve never done anything like this before and hope you guys can help me out

Advertisement

Answer

You need to write a daemon. Daemons are background processes without user interactions. You can call it cputempd. Then you need to make a client called cputemp that connects to your daemon and gets information.

Writing daemons is explained here with further references: Creating a daemon in Linux

For communication between your client program and your daemon there are different methods of Interprocess Communication although you can simply use socket programming. on IPC: http://www.tldp.org/LDP/lpg/node7.html

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement