Can anybody please post some example code on how I can reread a configuration file and restart my daemon after the daemon receives a SIGHUP signal. The daemon is a user spac
Depends how you structure it; if you handle multiple connections in a single thread / process, then you should probably somehow notify them to quit (if you can; depends on the protocol) before reloading the config (or exec itself).
If the protocol allows you to say "go away and come back later", then clearly doing that is a good win. If the clients need to remain connected, you could apply the config changes to already-connected clients, if it's a single-process-single-thread daemon, if that makes sense.
If it's multi process, things get more complex. You'd have to notify the processes about the new config, or ensure that they continue with the old config, or that they can pick the new config up when their client quits.
If it's multi thread, the threads would need to safely be able to read the new config in the middle of whatever they happened to be doing, which might need locking, or you could allocate memory for a new config structure and do a switch-over somehow,