Tagged Questions
5
votes
1answer
352 views
“trap … INT TERM EXIT” really necessary?
Many examples for trap use trap ... INT TERM EXIT for cleanup tasks. But is it really necessary to list all the three sigspecs?
The manual says:
If a SIGNAL_SPEC is EXIT (0) ARG is executed on ...
0
votes
0answers
110 views
Trap signals by an external shell on bash?
I tried to do this script:
#!/bin/bash
trap "echo trapped!" SIGUSR2
sleep 3s
kill -SIGUSR2 $$;
exit 0
and it works because it kills itself "from the inner".
if i try this
#!/bin/bash
trap "echo ...
3
votes
3answers
2k views
How to stop the loop bash script in terminal?
For example,
#!/bin/bash
while :
do
sl
done
How to terminate this bash script?
1
vote
1answer
507 views
Trap, ERR, and echoing the error line
I'm trying to create some error reporting using a Trap to call a function on all errors:
Trap "_func" ERR
Is it possible to get what line the ERR signal was sent from? The shell is bash.
If I do ...
3
votes
3answers
1k views
How to setup trap in bash functions?
I can setup trap in bash scripts but not bash functions.
For example, source the code below and run f, now try Ctrl+C, it's not been trapped!
How to setup trap in bash functions?
4 trap ctrl_c ...
3
votes
2answers
1k views
How can I trap a program that returns 139 (segmentation fault) in bash?
I have a bash script that tests some programs and one of the program returns Segmentation fault so I tried to add a trap in the head of my script:
trap "echo 'segfault occured!'" SIGSEGV
That ...
3
votes
2answers
364 views
Wrapper program that sets signal handler
I would like to have a wrapper program that runs a given command and sets a signal handler so that it gets run when the command receives a specified signal.
The question is this:
Is there an ...
3
votes
2answers
243 views
Bash: keybinding/trap issue
My .bashrc has the following:
# Alt+L lists current directory
bind -x "\"\el\":ls -ltrF --color=auto;"
# trap commands and echo them to xterm titlebar.
trap 'echo -ne "\033]0;$BASH_COMMAND - ...
2
votes
1answer
1k views
What is signal 0 in a trap command?
I'm following this guide on how to set up passwordless SSH authentication with ssh-agent.
To start up ssh-agent the author recommends the following code in .bash_profile:
SSHAGENT=/usr/bin/ssh-agent
...
