pipe_path="$(mktemp -u)"
mkfifo "$pipe_path"
exec 3<>"$pipe_path"
rm -f "$pipe_path"
Here, exec associates the file descriptor (3 here, replace with any desired descriptor) with the pipe created by mkfifo. The filesystem path to the pipe is removed immediately after we obtain a file descriptor to it, so that the the only remaining reference to the pipe in the system would be from this script, and thus when the script dies, the kernel will automatically free the pipe.An example use case would be like so: https://unix.stackexchange.com/a/216475/585293