|
From: | Chet Ramey |
Subject: | Re: bash 5.1 heredoc pipes problematic, shopt needed |
Date: | Mon, 25 Apr 2022 09:14:32 -0400 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 |
My pipe size is 4kb, but... ulimit -p 8{ file /proc/self/fd/0; } <<<"$(dd if=/dev/urandom bs=1 count=$((4096*16)))"/proc/self/fd/0: symbolic link to pipe:[1427240]{ file /proc/self/fd/0; } <<<"$(dd if=/dev/urandom bs=1 count=$((4096*17)))"/proc/self/fd/0: symbolic link to /tmp/sh-thd.Npifok (deleted) Only from size 65Kb it's became a file. BASH 5.1.16
It's a good question. There's no system call for the kernel to report the `pipe size', which is a fluid concept. There are only a couple of shells that syntheize a value for it: bash and ksh93. Bash uses the value of PIPE_BUF, which is defined on POSIX systems as the maximum number of bytes that can be written to a pipe atomically. That's the 4096 number. The pipe capacity is the number of bytes that can be written to the pipe -- by any process -- without being read, before writes block or fail. That's 64K on Linux. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
[Prev in Thread] | Current Thread | [Next in Thread] |