#!/bin/bash trap 'rm -f fifo' EXIT mkfifo fifo || exit : > fifo & exec 3< fifo read <&3 || echo EOF # A writer opens, writes and closes after the reader has observed EOF but # before the reader closes its end. echo two > fifo && echo "wrote two" # Closing the last open descriptor on the fifo discards the unread data (in any # process). exec 3<& echo three > fifo & cat fifo