Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Runtime configuration of a C application for Linux

Tags:

c

linux

gcc

We have a C application for Linux consisting of few modules. Each module can have some global config variables (some integers, strings etc.). The application is intended to run as a daemon for a long time.

What is the nicest way to reconfigure the app during run-time? Ideally, we would like to change somehow the content of those config-variables. Via /proc, inotify? What's the coolest, advanced way?

like image 901
Cartesius00 Avatar asked Jan 22 '26 07:01

Cartesius00


1 Answers

Sending a signal like SIGHUP which your program traps with a signal handler and does whatever it needs to do, like re-reading its configuration file, is a time-honored way of doing this. I can't call it a "coolest advanced" way, rather a practical and easy way. It is, for example, what happens when you want Apache's httpd daemon to re-read httpd.conf - it happens under the hood of service httpd reload.

like image 157
e.dan Avatar answered Jan 24 '26 22:01

e.dan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!