How can I test that the bash interactive shell handles the signal using the handler that I set up via `trap`?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
In a bash interactive shell, when I run a trap
command (e.g. trap "echo You hit control-C!" INT
) to set up a signal handler, does that set up how the bash interactive shell handles the signal?
How can I test that the bash interactive shell handles the signal by using the handler that I set up via trap
?
Is it possible to test i.e. to generate the signal
- within the bash interactive shell?
- within the terminal emulator where the shell runs?
Or must I test from the outside of the bash interactive shell, or outside the terminal emulator?
Thanks.
bash signals trap
add a comment |Â
up vote
0
down vote
favorite
In a bash interactive shell, when I run a trap
command (e.g. trap "echo You hit control-C!" INT
) to set up a signal handler, does that set up how the bash interactive shell handles the signal?
How can I test that the bash interactive shell handles the signal by using the handler that I set up via trap
?
Is it possible to test i.e. to generate the signal
- within the bash interactive shell?
- within the terminal emulator where the shell runs?
Or must I test from the outside of the bash interactive shell, or outside the terminal emulator?
Thanks.
bash signals trap
What do you expect to happen, and what's happening instead? The definition of trap is "The commands in arg are to be read and executed when the shell receives signal sigspec."
â Jeff Schaller
Oct 19 '17 at 23:38
I would like to know how to show that an interactive shell reacts to a signal for which a trap has been set in it.
â Tim
Oct 20 '17 at 1:17
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In a bash interactive shell, when I run a trap
command (e.g. trap "echo You hit control-C!" INT
) to set up a signal handler, does that set up how the bash interactive shell handles the signal?
How can I test that the bash interactive shell handles the signal by using the handler that I set up via trap
?
Is it possible to test i.e. to generate the signal
- within the bash interactive shell?
- within the terminal emulator where the shell runs?
Or must I test from the outside of the bash interactive shell, or outside the terminal emulator?
Thanks.
bash signals trap
In a bash interactive shell, when I run a trap
command (e.g. trap "echo You hit control-C!" INT
) to set up a signal handler, does that set up how the bash interactive shell handles the signal?
How can I test that the bash interactive shell handles the signal by using the handler that I set up via trap
?
Is it possible to test i.e. to generate the signal
- within the bash interactive shell?
- within the terminal emulator where the shell runs?
Or must I test from the outside of the bash interactive shell, or outside the terminal emulator?
Thanks.
bash signals trap
asked Oct 19 '17 at 22:44
Tim
22.9k66225407
22.9k66225407
What do you expect to happen, and what's happening instead? The definition of trap is "The commands in arg are to be read and executed when the shell receives signal sigspec."
â Jeff Schaller
Oct 19 '17 at 23:38
I would like to know how to show that an interactive shell reacts to a signal for which a trap has been set in it.
â Tim
Oct 20 '17 at 1:17
add a comment |Â
What do you expect to happen, and what's happening instead? The definition of trap is "The commands in arg are to be read and executed when the shell receives signal sigspec."
â Jeff Schaller
Oct 19 '17 at 23:38
I would like to know how to show that an interactive shell reacts to a signal for which a trap has been set in it.
â Tim
Oct 20 '17 at 1:17
What do you expect to happen, and what's happening instead? The definition of trap is "The commands in arg are to be read and executed when the shell receives signal sigspec."
â Jeff Schaller
Oct 19 '17 at 23:38
What do you expect to happen, and what's happening instead? The definition of trap is "The commands in arg are to be read and executed when the shell receives signal sigspec."
â Jeff Schaller
Oct 19 '17 at 23:38
I would like to know how to show that an interactive shell reacts to a signal for which a trap has been set in it.
â Tim
Oct 20 '17 at 1:17
I would like to know how to show that an interactive shell reacts to a signal for which a trap has been set in it.
â Tim
Oct 20 '17 at 1:17
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You can test a handler from inside the shell itâÂÂs set up in, by using kill
to send a signal to the current shell:
kill -INT $$
Change -INT
to match the trap you wish to test.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You can test a handler from inside the shell itâÂÂs set up in, by using kill
to send a signal to the current shell:
kill -INT $$
Change -INT
to match the trap you wish to test.
add a comment |Â
up vote
3
down vote
accepted
You can test a handler from inside the shell itâÂÂs set up in, by using kill
to send a signal to the current shell:
kill -INT $$
Change -INT
to match the trap you wish to test.
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You can test a handler from inside the shell itâÂÂs set up in, by using kill
to send a signal to the current shell:
kill -INT $$
Change -INT
to match the trap you wish to test.
You can test a handler from inside the shell itâÂÂs set up in, by using kill
to send a signal to the current shell:
kill -INT $$
Change -INT
to match the trap you wish to test.
answered Oct 20 '17 at 4:23
Stephen Kitt
144k22314378
144k22314378
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399231%2fhow-can-i-test-that-the-bash-interactive-shell-handles-the-signal-using-the-hand%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
What do you expect to happen, and what's happening instead? The definition of trap is "The commands in arg are to be read and executed when the shell receives signal sigspec."
â Jeff Schaller
Oct 19 '17 at 23:38
I would like to know how to show that an interactive shell reacts to a signal for which a trap has been set in it.
â Tim
Oct 20 '17 at 1:17