Signal handler not called when trying to open fifo
I'm trying to recover from the state where a fifo reader is unexpectedly unavailable. My idea is to signal the writer process after timeout, to avoid it hanging forever:
mkfifo fifo
timeout 1 sh -c 'trap "echo cleanup...; exit" TERM; exec 3>fifo'
This works when using bash or zsh but with dash my signal handler is never called. Instead I get
sh: 1: cannot create fifo: Interrupted system call
Is this supposed to work?
Quoted 8 lines · Johannes Altmanninger
I'm trying to recover from the state where a fifo reader is unexpectedly unavailable. My idea is to signal the writer process after timeout, to avoid it hanging forever:
mkfifo fifo
timeout 1 sh -c 'trap "echo cleanup...; exit" TERM; exec 3>fifo'This works when using bash or zsh but with dash my signal handler is never called.
I realized I can work around this using
timeout sh ... if [ $? -eq 124 ]; then cleanup; fi
That works for me.
Quoted 5 lines
Instead I get
sh: 1: cannot create fifo: Interrupted system call
Is this supposed to work?