Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: implementation of <() (creating a temp fifo) ?



On Feb 12,  4:32am, Timothee Cour wrote:
}
} Could someone kindly point me source code showing how zsh implements <()
} (temporary named pipe creation)? (ideally a url)
} 
} * my workaround is to use tempnam but docs says it's not recommended (
} http://man7.org/linux/man-pages/man3/tempnam.3.html)

There doesn't seem to be any better option for a temporary named pipe.
mkfifo is relatively safe because there's no way to cause it to re-use
an existing fifo, so as long as you're confident that the directory
where the fifo is placed cannot itself be spoofed, using tempnam is OK.

Note that the default build mode for zsh is to instead use /dev/fd/ or
the equivalent to get a handle to the stdin or stdout of the process,
and not use a named pipe at all.

Also since any process can connect to a named pipe once it exists, be
sure you're passing appropriately restrictive file modes to mkfifo.

To answer your direct question:

https://sourceforge.net/p/zsh/code/ci/master/tree/Src/exec.c
   search for "namedpipe"

https://sourceforge.net/p/zsh/code/ci/master/tree/Src/utils.c
   search for "gettempname"



Messages sorted by: Reverse Date, Date, Thread, Author