-1

With the following script running in window1

#!/bin/bash

function handler
{
  echo "the time is $(date)" >> /tmp/zz
}

rm /tmp/zz
trap handler USR1
echo "This is $$"
cat

In window2 I am sending a signal with "kill -USR1 PID_OF_WINDOW1_SCRIPT"

The /tmp/zz file is non existant after I send the signal

I'm pretty sure that this used to work for me in the past Any idea?

1 Answer 1

1

The shell isn't free to call your handler until cat completes. Type an end-of-file character (Controld) to end cat, which lets the shell run your handler and exit.

1
  • Thanks .. I actually just figured it out a minute before (reading tldp.org/LDP/Bash-Beginners-Guide/html/sect_12_02.html) ... cat in this case was just a place-holder for a another long running process that I do not want to kill ... I will use alternate solutions to my need
    – nhed
    Feb 28, 2013 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.