Server Wait On Clients System - API Documentation  v1.6.4
Server Wait On Clients System.
signalhandle.c File Reference

Signal handling functions. More...

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <swoc/libswocserver.h>
#include <swoc/signalhandle.h>
Include dependency graph for signalhandle.c:

Functions

void init_sig_handle (void)
 Initialise signal handler. More...
 
void termination_handler (int signum)
 Handler for caught signals. More...
 

Detailed Description

Signal handling functions.

Likely terminate signals to handle.

SIGTERM
SIGINT (Ctrl-C)
SIGQUIT (Ctrl-)
SIGHUP
Might want to handle these non-terminate signals.

SIGCONT
SIGTSTP (Ctrl-Z)

Author
Copyright (C) 2015-2019, 2021, 2022 Mark Grant

Released under the GPLv3 only.
SPDX-License-Identifier: GPL-3.0-only

Version
v1.0.9 ==== 17/09/2022

Function Documentation

◆ init_sig_handle()

void init_sig_handle ( void  )

Initialise signal handler.

Block all other caught signals whilst the handler processes.

◆ termination_handler()

void termination_handler ( int  signum)

Handler for caught signals.

There are 2 possibilities here:-
Catch, process and terminate
or
Catch, process and continue.

Catch, process and terminate is straight forward as the easiest way to terminate is to re-raise the signal using the default hander.

Catch, process and continue has 2 forms:-
Continue via simple return
or
Continue via re-raise the signal using the default handler.

The simple return is just that.

Re-raise the signal using the default handler is required for instance with SIGTSTP (Ctrl-Z). This is because in a terminal the default handler ensures the stopped process is in the background and control is passed back to the shell, (fg can then be used to resume the process). This means that SIGTSTP is now set to use the default handler, hence this relies on SIGCONT to explicitly reset the SIGTSTP handler.

Parameters
signumThe signal number.