Interesting development idea

6 views
Skip to first unread message

Jeff Cauhape

unread,
May 21, 2019, 6:10:42 PM5/21/19
to Reno Linux Users Group
I've spent a number of years doing tech support for various products, and one thing that bothered
me was that if you needed to change the configuration of a running program, you almost always
need to stop and restart it. If you're working with some program running like a daemon process
in a production environment, it can take hours to days to get permission to restart the program,
as undoubtedly other programs are either giving it input or expecting output and turning it off
has to be a coordinated effort.

What a PITA.

I thought there has to be a better way to do this. What I would like to suggest is that if you
have a program running in a loop like a daemon of some sort, use the "user signals" SIGUSR1
or SIGUSR2 to notify the running program that it should re-read the configuration file at it's
next opportunity. 

The "kill" program is used to send signals to a running program. Usually it is used to kill a
program by giving the command:

# kill -9 <process_id>

The "-9" in the signal number being sent to the program identified by the process ID.

If you look at the kill man page, it will lead you to /usr/include/linux/signal.h, which in
turn includes /usr/include/asm/signal.h, which contains this bit of info:

#define SIGHUP           1
#define SIGINT           2
#define SIGQUIT          3
#define SIGILL           4
#define SIGTRAP          5
#define SIGABRT          6
#define SIGIOT           6
#define SIGBUS           7
#define SIGFPE           8
#define SIGKILL          9
#define SIGUSR1         10
#define SIGSEGV         11
#define SIGUSR2         12
#define SIGPIPE         13
#define SIGALRM         14
#define SIGTERM         15
...

and from that you see that SIGUSR1 is signal 10 and SIGUSR2 is signal 12.

If you have written your program to trap signals, you can tell it to re-read the
config file with just

# kill -10 <process_id>

In fact, you might take this one step further by having one signal tell the running
program to just go check the syntax of the config file, and use the other to command
it to re-read and USE the new information in the config file.

Just my 2 cents.

Jeff


Reply all
Reply to author
Forward
0 new messages