Reputation: 2735
I have a shell script in which I can use "trap" command to capture the signals sent.
It will execute some function when specific signals are received.
I use the "kill" command to send the signal.
I just want to trigger the function in the script while not really kill the script.
Originally I thought the SIGUSR1
and SIGUSR2
should work, but I am wrong, the script just exited.
So is there a way to just use kill to send a signal to trigger some functions without really killing the process?
Upvotes: 1
Views: 1367
Reputation: 799
I believe it's rarely used, but I know of one common case you can reference.
dd
you can send a USR1 signal to dd while running and it will output progress. Entirely userland and works great, fully portable code too. Reference: http://en.wikipedia.org/wiki/Dd_(Unix)
Upvotes: 3
Reputation: 121
According to the man pages for kill and signal(7), the best you could hope for would be to stop and then maybe continue. But I don't think that will do what you want. I also question the desire to use "kill", a command whose name makes its intended purpose very clear, to do this. Almost every signal you can send with kill is intended to terminate a process or cause it to dump core. I'm not an expert but I think you are trying to use the wrong tool here.
Upvotes: 1