Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
blaar
blibs
blc_program
Commits
3b01d657
Commit
3b01d657
authored
Sep 28, 2017
by
Arnaud Blanchard
Browse files
Manage SIGTERM, SIGTSTP, SIGCONT signals
parent
800629a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/blc_command.cpp
View file @
3b01d657
...
...
@@ -116,7 +116,7 @@ void blc_command_remove(const char *command_name){
}
if
(
i
==-
1
)
EXIT_ON_ERROR
(
"You try to remove a command '%s' that does not exist"
,
command_name
);
REMOVE_ITEM
(
&
blc_commands
,
&
blc_commands_nb
,
i
);
REMOVE_ITEM
_POSITION
(
&
blc_commands
,
&
blc_commands_nb
,
i
);
}
void
blc_command_interpret_string
(
char
const
*
input_string
,
size_t
size
){
...
...
src/blc_program.cpp
View file @
3b01d657
...
...
@@ -408,10 +408,20 @@ void blc_program_args_display_help()
}
static
void
on_sigterm
(
int
){
fprintf
(
stderr
,
"%s: receiving SIGTERM
(kill)
\n
"
,
blc_program_id
);
fprintf
(
stderr
,
"%s: receiving SIGTERM
\n
"
,
blc_program_id
);
exit
(
EXIT_SUCCESS
);
}
static
void
on_sigtstp
(
int
){
fprintf
(
stderr
,
"%s: receiving SIGTSTP: pause
\n
"
,
blc_program_id
);
blc_status
=
BLC_PAUSE
;
}
static
void
on_sigcont
(
int
){
fprintf
(
stderr
,
"%s: receiving SIGCONT: continue
\n
"
,
blc_program_id
);
blc_status
=
BLC_RUN
;
}
static
void
on_sigint
(
int
){
if
(
blc_status
==
BLC_QUIT
){
fprintf
(
stderr
,
"%s: receiving SIGINT (Ctrl+C) in quiting mode. Force to quit.
\n
"
,
blc_program_id
);
...
...
@@ -424,7 +434,7 @@ static void on_sigint(int){
}
static
void
on_sigsegv
(
int
){
fprintf
(
stderr
,
"%s: segmentation fault ( memory access error
!
)
\n
"
,
blc_program_id
);
fprintf
(
stderr
,
"%s:
receiving SIGSEGV
segmentation fault ( memory access error )
\n
"
,
blc_program_id
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -444,6 +454,12 @@ void blc_program_init(int *argc, char ***argv, void (*exit_cb)(void))
action
.
sa_handler
=
on_sigterm
;
SYSTEM_SUCCESS_CHECK
(
sigaction
(
SIGTERM
,
&
action
,
0
),
0
,
NULL
);
action
.
sa_handler
=
on_sigtstp
;
SYSTEM_SUCCESS_CHECK
(
sigaction
(
SIGTSTP
,
&
action
,
0
),
0
,
NULL
);
action
.
sa_handler
=
on_sigcont
;
SYSTEM_SUCCESS_CHECK
(
sigaction
(
SIGCONT
,
&
action
,
0
),
0
,
NULL
);
action
.
sa_handler
=
on_sigint
;
SYSTEM_SUCCESS_CHECK
(
sigaction
(
SIGINT
,
&
action
,
0
),
0
,
NULL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment