====== Kill Signals ======
The [[:start|crossfire]] main binary [[:server]] handles several signals sent to it :
- **1** SIGHUP
- **2** SIGINT
- **3** SIGQUT
- **7** SIGBUS
- **11** SIGSEGV
- **13** SIGPIPE
- **15** SIGTERM
==== 1 Hang Up [SIG]HUP ====
This signal forces the crossfire [[:server]] unfortunately not
to reload the configuration files, \\
but reopens the log file in append mode,
if the logging output is not send to stderr ( of some terminal ) .
Syntax : ''kill -1 `pidof crossfire-server`''
The whole path to the logfile is defined in //server/include/config.h// as absolute path-name :
* Windows : #define LOGFILE "var\\crossfire.log"
* #else : #define LOGFILE "/var/log/crossfire/logfile"
The //configure// script inside the [[:server:server_compiling|source]] does not alter that path, even when the //--prefix// option had been applied. \\
The server may choke at start up, if the directory //var// or // /var/log/crossfire// does not exist, \\ or has not set proper writable permissions.
The source code file //server/common.logger.c// opens the existing logfile \\
in append mode inside the function //void LOG (LogLevel logLevel, const char *format, ...)// :
if ((logfile = fopen(settings.logfilename, "a")) == NULL)
"a" means append :
>**a** Open for appending (writing at end of file). The file is
> created if it does not exist. The stream is positioned at the
> end of the file.
From manual page [[http://man7.org/linux/man-pages/man3/fopen.3.html]]
FIXME It makes no sense to append to a logfile; I have a 55 MB logfile and would like the idea, to completely overwrite it, without the need to shut down the server entirely. \\
In the case of a long-time running server like the [[:servers:metalforge]] one , this log file could crash the Operating System because of it's sheer size ( filling up the partition ).
==== 2 Interrupt [SIG}INT ====
This signal actually shutdowns the crossfire server,
with leaving a message about it in the logfile,
having received that signal. Calls //fatal_signal(0, 1)// .
Syntax : ''kill -2 `ps -o pid,args | grep -e 'crossfire-server' | grep -v 'grep' | awk '{print $1}'`'' \\
Of course, //pidof// is much easier to use ... :-)
==== 3 Quit [SIG]QUIT ====
Writes log at level info and calls //fatal_signal(1, 1)// .
==== 7 [SIG]BUS ====
Only handled if //#ifdef SIGBUS// was defined at [[:server:server compiling]] time;
writes to log level error and calls //fatal_signal(1, 1)//
==== 11 Segmentation Fault [SIG]SEGV ====
Should write to log level error and calls //fatal_signal(1, 1)// .
==== 13 [SIG]PIPE ====
On Windows OS writes at log level error and calls //fatal_signal(1, 1)//, on other Operating Systems writes at log level info and is otherwise ignored.
==== 15 Termination [SIG]TERM ====
Writes at log level info and calls //fatal_signal(0, 1)// .
===== Technical =====
The file that contains the signal handling code is server/server/init.c \\
Functions are named //rec_sigNAME// like
void rec_sigint(int i) {
LOG(llevInfo,"\nSIGINT received.\n");
fatal_signal(0, 1);
}
Except for //rec_sighup// , these functions all call the function fatal_signal with the parameters to make_core and close_sockets .
void fatal_signal(int make_core, int close_sockets) {
if(init_done) {
emergency_save(0);
clean_tmp_files();
}
if(make_core)
abort();
exit(0);
}