• Bug#1108971: bash: computes wrong PIPESIZE during some cross builds (2/

    From Helmut Grohne@1:229/2 to All on Tue Jul 8 21:00:01 2025
    [continued from previous message]

    - along with Bash. If not, see <http://www.gnu.org/licenses/>.
    -*/
    -
    -/* Write output in 128-byte chunks until we get a sigpipe or write gets an
    - EPIPE. Then report how many bytes we wrote. We assume that this is the
    - pipe size. */
    -#include <config.h>
    -
    -#if defined (HAVE_UNISTD_H)
    -# ifdef _MINIX
    -# include <sys/types.h>
    -# endif
    -# include <unistd.h>
    -#endif
    -
    -#include <stdio.h>
    -#ifndef _MINIX
    -#include "../bashtypes.h"
    -#endif
    -#include <signal.h>
    -#include <errno.h>
    -
    -#include "../command.h"
    -#include "../general.h"
    -#include "../sig.h"
    -
    -#ifndef errno
    -extern int errno;
    -#endif
    -
    -int nw;
    -
    -sighandler
    -sigpipe (sig)
    - int sig;
    -{
    - fprintf (stderr, "%d\n", nw);
    - exit (0);
    -}
    -
    -int
    -main (argc, argv)
    - int argc;
    - char **argv;
    -{
    - char buf[128];
    - register int i;
    -
    - for (i = 0; i < 128; i++)
    - buf[i] = ' ';
    -
    - signal (SIGPIPE, sigpipe);
    -
    - nw = 0;
    - for (;;)
    - {
    - int n;
    - n = write (1, buf, 128);
    - nw += n;
    - }
    - return (0);
    -}
    --- bash-5.2.37.orig/builtins/ulimit.def
    +++ bash-5.2.37/builtins/ulimit.def
    @@ -92,7 +92,6 @@
    #include "../shell.h"
    #include "common.h"
    #include "bashgetopt.h"
    -#include "pipesize.h"

    #if !defined (errno)
    extern int errno;
    --- bash-5.2.37.orig/config.h.in
    +++ bash-5.2.37/config.h.in
    @@ -243,6 +243,9 @@

    #define DEFAULT_MAIL_DIRECTORY "/usr/spool/mail"

    +/* The amount of bytes one can write to a pipe(2) before it blocks. */
    +#undef PIPESIZE
    +
    /* Characteristics of the system's header files and libraries that affect
    the compilation environment. */

    --- bash-5.2.37.orig/redir.c
    +++ bash-5.2.37/redir.c
    @@ -58,8 +58,6 @@
    # include "input.h"
    #endif

    -#include "builtins/pipesize.h"
    -
    /* FreeBSD 13 can reliably handle atomic writes at this capacity without
    hanging. */
    #if __FreeBSD__ && !defined (HEREDOC_PIPESIZE)
    --- bash-5.2.37.orig/builtins/psize.sh
    +++ /dev/null
    @@ -1,45 +0,0 @@
    -#! /bin/sh
    -#
    -# psize.sh -- determine this system's pipe size, and write a