I hear that for named pipes, writes that are smaller than about 512bytes are atomic (the writes won't interleave).
Is there a way to increase that amount for a specific named pipe?
something like:
mkfifo mynamedpipe --buf=2500
Supposedly this is the full documentation:
http://www.gnu.org/software/coreutils/manual/html_node/mkfifo-invocation.html#mkfifo-invocation
man mkfifo
takes me to that page.
Best Answer
A
fifo
file is just a type of file which when opened for both reading and writing instantiates a pipe like a pipe() system call would.On Linux at least, the data that transits though that pipe is not stored on the file system at all (only in the kernel as kernel memory). And the size attribute of the fifo file is not relevant and is always 0.
On Linux, you can change the size of a pipe buffer (whether that pipe has been instantiated with
pipe()
or via opening a fifo file) with theF_SETPIPE_SZ
fcntl()
, though for unprivileged users, that's bound by/proc/sys/fs/pipe-max-size
. Any of the writer or reader to the pipe can issue thatfcntl()
though it makes more sense for the writer to do it. In the case of a named pipe, you'd need to do that for each pipe instantiated though the fifo file.Above, I used
perl
to issue thefcntl()
, harcoding the value ofF_SETPIPE_SZ
(1031 on my system).