Skip to content
Snippets Groups Projects
Commit 70109188 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

allow to pass signal by name or its number

parent 22c850aa
No related branches found
No related tags found
No related merge requests found
......@@ -239,7 +239,7 @@ extern char const *help_halt ;
#define OPTS_STOP_LEN (sizeof OPTS_STOP - 1)
#define OPTS_STATUS "hno:grd:p:"
#define OPTS_STATUS_LEN (sizeof OPTS_STATUS - 1)
#define OPTS_SIGNAL "habqHkti12pcyrodDuUxOQw:P"
#define OPTS_SIGNAL "habqHkti12pcys:rodDuUxOQw:P"
#define OPTS_SIGNAL_LEN (sizeof OPTS_SIGNAL - 1)
#define OPTS_ENV "hc:s:VLr:e:i:"
#define OPTS_ENV_LEN (sizeof OPTS_ENV - 1)
......
......@@ -20,6 +20,7 @@
#include <oblibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/nsig.h>
#include <66/svc.h>
#include <66/config.h>
......@@ -29,6 +30,22 @@
#include <66/state.h>
#include <66/enum.h>
static char const cmdsig[NSIG] = {
[SIGALRM] = 'a',
[SIGABRT] = 'b',
[SIGQUIT] = 'q',
[SIGHUP] = 'h',
[SIGKILL] = 'k',
[SIGTERM] = 't',
[SIGINT] = 'i',
[SIGUSR1] = '1',
[SIGUSR2] = '2',
[SIGSTOP] = 'p',
[SIGCONT] = 'c',
[SIGWINCH] = 'y'
} ;
int ssexec_signal(int argc, char const *const *argv, ssexec_t *info)
{
log_flow() ;
......@@ -77,6 +94,15 @@ int ssexec_signal(int argc, char const *const *argv, ssexec_t *info)
if (opt == -1) break ;
switch (opt) {
case 's' :
{
int sig ;
if (!sig0_scan(l.arg, &sig))
log_die(LOG_EXIT_USER, "invalid signal: ", l.arg) ;
if (!cmdsig[sig])
log_die(LOG_EXIT_USER, l.arg, " is not in the list of user-available signals") ;
opt = cmdsig[sig] ;
}
case 'h' : info_help(info->help, info->usage) ; return 0 ;
case 'a' :
case 'b' :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment