Skip to contentSkip to conversation

Signal handler not called when trying to open fifo

DISCUSSION Johannes Altmanninger 1 participant 2 messages Sep 26, 2024

lore
Share & tools
lore
#0 lore raw

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?

#1 lore raw
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?