From unknown Tue Sep 09 22:28:54 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33761: Allow split to write into FIFOs Resent-From: scottworley@scottworley.com Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sat, 15 Dec 2018 15:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33761 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 33761@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.154488797632136 (code B ref -1); Sat, 15 Dec 2018 15:33:01 +0000 Received: (at submit) by debbugs.gnu.org; 15 Dec 2018 15:32:56 +0000 Received: from localhost ([127.0.0.1]:49533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYBvy-0008ME-Ue for submit@debbugs.gnu.org; Sat, 15 Dec 2018 10:32:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39625) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gY5Ga-0003mO-No for submit@debbugs.gnu.org; Sat, 15 Dec 2018 03:25:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gY5GU-00082a-Id for submit@debbugs.gnu.org; Sat, 15 Dec 2018 03:25:39 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57521) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gY5GU-00082Q-CI for submit@debbugs.gnu.org; Sat, 15 Dec 2018 03:25:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gY5GT-00088L-50 for bug-coreutils@gnu.org; Sat, 15 Dec 2018 03:25:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gY5GP-0007wc-G4 for bug-coreutils@gnu.org; Sat, 15 Dec 2018 03:25:37 -0500 Received: from 75-145-22-45-washington.hfc.comcastbusiness.net ([75.145.22.45]:41860 helo=chkno.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gY5GO-0007fp-JV for bug-coreutils@gnu.org; Sat, 15 Dec 2018 03:25:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=scottworley.com; s=20181127; h=Content-Type:MIME-Version:Message-ID:Subject :To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=fPwpV36xQusBbnLHSQ1vKFwgL0DXxwmAC/VKfXJDLmk=; b=kZrRFQwWbbUWtVj+vuWHcC1dXS m97PPYwe08c/PqK0BzEXZNMw7j5W5x4lDPISPDZPw+ur/qYlOHQwFqjMV7xCk2cVTzHde/Odf85vB 8JcMcyVBW3FT6XIIhParY4IuEVnQrAnYoP66iHLlQW400vs8JxrzCsUBy6/tAL27nGTxW1PRByN/F p+EuR8/cHPCn78i+gqPcU69+FnTFQmIAmIGWxJW9W9PUNUMJ/xkcKiKYSzW6OUcOjfajXyOGQzlnq blIoI3VCCkpddI9BFHSpOBOgN3uQmhRTrsUD9H1Q313r2s2/FIee8A8mxv0y5PBJ1RWxYMWazTjlO pSPscoqQ5XiLQvwZTBiUuCYQb6eTEAShTADJNaYpgqA2agEPkSh47NgE/UrP8vH8BZORQUCUdh1ZF wgwVsdr9xiDjau394nzyA9rFVoRCc3hi5A4Rt85RPteFggPL0LKr0qB97kJhPN1yRNC7mstWvLSlZ 4cLCFR6mdcjyhRw9e5E6TjjLM44LnWOJfEwZNHaWFD8gVkndxSVn9iXkHOijY5jNlVMhkIujQRajt sEqzWOAkGhY9ZKasfhgTZaqRYMqrCZ+CyVdsxzgAFoeuO4/12FF8f1JunprZPs+xWCUG5tn5RnC24 uffntWvblkQmAUh+/dj5d1Eo3IsizF2sBsapuBhc4=; Received: from chkno by chkno.net with local (Exim 4.91) (envelope-from ) id 1gY4ry-0001Yd-Tb for bug-coreutils@gnu.org; Sat, 15 Dec 2018 00:00:18 -0800 Date: Sat, 15 Dec 2018 00:00:18 -0800 From: scottworley@scottworley.com Message-ID: <20181215080018.GF703@chkno.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="fUYQa+Pmc3FrFX/N" Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: 0.9 (/) X-Mailman-Approved-At: Sat, 15 Dec 2018 10:32:53 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.1 (-----) --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline TL;DR: Attached: Patch to allow split to write into FIFOs. Currently, split fails when its output files are FIFOs because FIFOs cannot be ftruncate()d. Split exits with this error message: split: xaa: error truncating: Invalid argument The attached patch causes split to only attempt the ftruncate when its output is a regular file. --fUYQa+Pmc3FrFX/N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="coreutils-split-into-fifos.patch" --- coreutils-8.29/src/split.c.orig 2017-09-20 01:17:21.000000000 +0000 +++ coreutils-8.29/src/split.c 2018-12-15 07:37:31.000000000 +0000 @@ -470,7 +470,7 @@ if (SAME_INODE (in_stat_buf, out_stat_buf)) die (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"), quoteaf (name)); - if (ftruncate (fd, 0) != 0) + if (S_ISREG(out_stat_buf.st_mode) && ftruncate (fd, 0) != 0) die (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name)); return fd; --- coreutils-8.29/Makefile.in.orig 2017-12-27 18:25:58.000000000 +0000 +++ coreutils-8.29/Makefile.in 2018-12-15 07:03:11.000000000 +0000 @@ -5491,6 +5491,7 @@ tests/split/additional-suffix.sh \ tests/split/b-chunk.sh \ tests/split/fail.sh \ + tests/split/fifo.sh \ tests/split/lines.sh \ tests/split/line-bytes.sh \ tests/split/l-chunk.sh \ --- /dev/null 2018-08-27 15:55:28.530128552 +0000 +++ coreutils-8.29/tests/split/fifo.sh 2018-12-15 07:36:50.000000000 +0000 @@ -0,0 +1,47 @@ +#!/bin/sh +# Verify that output can be written to FIFOs + +# Copyright (C) 2002-2017 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ split + +printf '1\n2\n3\n' > in || framework_failure_ + +cat <<\EOF > exp-1 +1 +2 +EOF +cat <<\EOF > exp-2 +3 +EOF + +mkfifo xaa xab || framework_failure_ + +split --lines=2 in > out & +split_pid=$! + +for f in xaa xab;do + timeout 10 cat "$f" > "$f-data" +done + +wait "$split_pid" || fail=1 + +compare exp-1 xaa-data || fail=1 +compare exp-2 xab-data || fail=1 +test -f xac && fail=1 + +Exit $fail --fUYQa+Pmc3FrFX/N-- From unknown Tue Sep 09 22:28:54 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: scottworley@scottworley.com Subject: bug#33761: closed (Re: bug#33761: Allow split to write into FIFOs) Message-ID: References: <48dcbb21-638a-3f98-4760-3d16a6f71460@cs.ucla.edu> <20181215080018.GF703@chkno.net> X-Gnu-PR-Message: they-closed 33761 X-Gnu-PR-Package: coreutils Reply-To: 33761@debbugs.gnu.org Date: Sat, 15 Dec 2018 20:21:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1544905262-18919-1" This is a multi-part message in MIME format... ------------=_1544905262-18919-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #33761: Allow split to write into FIFOs which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 33761@debbugs.gnu.org. --=20 33761: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D33761 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1544905262-18919-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 33761-done) by debbugs.gnu.org; 15 Dec 2018 20:20:12 +0000 Received: from localhost ([127.0.0.1]:49702 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYGPz-0004ti-K7 for submit@debbugs.gnu.org; Sat, 15 Dec 2018 15:20:11 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47730) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYGPw-0004tG-2o for 33761-done@debbugs.gnu.org; Sat, 15 Dec 2018 15:20:10 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 19CDB1608EE; Sat, 15 Dec 2018 12:20:02 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 0Xkt4K9j4AgW; Sat, 15 Dec 2018 12:20:01 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 02A7A160987; Sat, 15 Dec 2018 12:20:01 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Czvj5iW9pBMo; Sat, 15 Dec 2018 12:20:00 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C20471608E4; Sat, 15 Dec 2018 12:20:00 -0800 (PST) Subject: Re: bug#33761: Allow split to write into FIFOs To: scottworley@scottworley.com, 33761-done@debbugs.gnu.org References: <20181215080018.GF703@chkno.net> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <48dcbb21-638a-3f98-4760-3d16a6f71460@cs.ucla.edu> Date: Sat, 15 Dec 2018 12:20:00 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181215080018.GF703@chkno.net> Content-Type: multipart/mixed; boundary="------------20FA9B271CD308044F0819D2" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33761-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------20FA9B271CD308044F0819D2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for reporting that. I see similar problems in a couple of other coreutils programs. The style elsewhere seems to be to try ftruncate first, and report an error if it fails only if the file is not one for which POSIX specifies the behavior, so I think it'd be better if 'split' did that too. So I installed the attached patch to fix the problems that I found, and this should fix the bug you reported so I'll close the bug report. Thanks also for the test case. To install that I'll need a copyright assignment form signed; can you do that for us? If so, please let me know and I'll get the paperwork ball rolling for you. --------------20FA9B271CD308044F0819D2 Content-Type: text/x-patch; name="0001-shred-sort-split-fix-ftruncate-error-reporting.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-shred-sort-split-fix-ftruncate-error-reporting.patch" >From 5af28df87d7af0736b2ad5e09ae6b3784f6af3af Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 15 Dec 2018 12:13:58 -0800 Subject: [PATCH] shred,sort,split: fix ftruncate error reporting Problem reported for split by Scott Worley (Bug#33761): * src/shred.c (do_wipefd): Also report an error if ftruncate fails on a shared memory object. * src/sort.c (get_outstatus): New function. (stream_open, avoid_trashing_input): Use it. * src/sort.c (stream_open): * src/split.c (create): If ftruncate fails, do not report an error unless it is a regular file or a shared memory object. --- src/shred.c | 10 ++++++---- src/sort.c | 39 ++++++++++++++++++++++++++------------- src/split.c | 3 ++- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/shred.c b/src/shred.c index 270b1e942..3a6510cf3 100644 --- a/src/shred.c +++ b/src/shred.c @@ -975,11 +975,13 @@ do_wipefd (int fd, char const *qname, struct randint_source *s, } } - /* Now deallocate the data. The effect of ftruncate on - non-regular files is unspecified, so don't worry about any - errors reported for them. */ + /* Now deallocate the data. The effect of ftruncate is specified + on regular files and shared memory objects (also directories, but + they are not possible here); don't worry about errors reported + for other file types. */ + if (flags->remove_file && ftruncate (fd, 0) != 0 - && S_ISREG (st.st_mode)) + && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st))) { error (0, errno, _("%s: error truncating"), qname); ok = false; diff --git a/src/sort.c b/src/sort.c index dd6bce47f..ebe86d3fb 100644 --- a/src/sort.c +++ b/src/sort.c @@ -895,8 +895,21 @@ create_temp_file (int *pfd, bool survive_fd_exhaustion) return node; } -/* Return a stream for FILE, opened with mode HOW. A null FILE means - standard output; HOW should be "w". When opening for input, "-" +/* Return a pointer to stdout status, or NULL on failure. */ + +static struct stat * +get_outstatus (void) +{ + static int outstat_errno; + static struct stat outstat; + if (outstat_errno == 0) + outstat_errno = fstat (STDOUT_FILENO, &outstat) == 0 ? -1 : errno; + return outstat_errno < 0 ? &outstat : NULL; +} + +/* Return a stream for FILE, opened with mode HOW. If HOW is "w", + the file is already open on standard output, and needs to be + truncated unless FILE is null. When opening for input, "-" means standard input. To avoid confusion, do not return file descriptors STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO when opening an ordinary FILE. Return NULL if unsuccessful. @@ -964,8 +977,13 @@ stream_open (char const *file, char const *how) else if (*how == 'w') { if (file && ftruncate (STDOUT_FILENO, 0) != 0) - die (SORT_FAILURE, errno, _("%s: error truncating"), - quotef (file)); + { + int ftruncate_errno = errno; + struct stat *outst = get_outstatus (); + if (!outst || S_ISREG (outst->st_mode) || S_TYPEISSHM (outst)) + die (SORT_FAILURE, ftruncate_errno, _("%s: error truncating"), + quotef (file)); + } fp = stdout; } else @@ -3699,8 +3717,6 @@ static void avoid_trashing_input (struct sortfile *files, size_t ntemps, size_t nfiles, char const *outfile) { - bool got_outstat = false; - struct stat outstat; struct tempnode *tempcopy = NULL; for (size_t i = ntemps; i < nfiles; i++) @@ -3713,18 +3729,15 @@ avoid_trashing_input (struct sortfile *files, size_t ntemps, same = true; else { - if (! got_outstat) - { - if (fstat (STDOUT_FILENO, &outstat) != 0) - break; - got_outstat = true; - } + struct stat *outst = get_outstatus (); + if (!outst) + break; same = (((is_stdin ? fstat (STDIN_FILENO, &instat) : stat (files[i].name, &instat)) == 0) - && SAME_INODE (instat, outstat)); + && SAME_INODE (instat, *outst)); } if (same) diff --git a/src/split.c b/src/split.c index 60c14d36c..1431bdf65 100644 --- a/src/split.c +++ b/src/split.c @@ -470,7 +470,8 @@ create (const char *name) if (SAME_INODE (in_stat_buf, out_stat_buf)) die (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"), quoteaf (name)); - if (ftruncate (fd, 0) != 0) + if (ftruncate (fd, 0) != 0 + && (S_ISREG (out_stat_buf.st_mode) || S_TYPEISSHM (&out_stat_buf))) die (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name)); return fd; -- 2.17.1 --------------20FA9B271CD308044F0819D2-- ------------=_1544905262-18919-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 Dec 2018 15:32:56 +0000 Received: from localhost ([127.0.0.1]:49533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYBvy-0008ME-Ue for submit@debbugs.gnu.org; Sat, 15 Dec 2018 10:32:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39625) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gY5Ga-0003mO-No for submit@debbugs.gnu.org; Sat, 15 Dec 2018 03:25:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gY5GU-00082a-Id for submit@debbugs.gnu.org; Sat, 15 Dec 2018 03:25:39 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57521) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gY5GU-00082Q-CI for submit@debbugs.gnu.org; Sat, 15 Dec 2018 03:25:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gY5GT-00088L-50 for bug-coreutils@gnu.org; Sat, 15 Dec 2018 03:25:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gY5GP-0007wc-G4 for bug-coreutils@gnu.org; Sat, 15 Dec 2018 03:25:37 -0500 Received: from 75-145-22-45-washington.hfc.comcastbusiness.net ([75.145.22.45]:41860 helo=chkno.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gY5GO-0007fp-JV for bug-coreutils@gnu.org; Sat, 15 Dec 2018 03:25:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=scottworley.com; s=20181127; h=Content-Type:MIME-Version:Message-ID:Subject :To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=fPwpV36xQusBbnLHSQ1vKFwgL0DXxwmAC/VKfXJDLmk=; b=kZrRFQwWbbUWtVj+vuWHcC1dXS m97PPYwe08c/PqK0BzEXZNMw7j5W5x4lDPISPDZPw+ur/qYlOHQwFqjMV7xCk2cVTzHde/Odf85vB 8JcMcyVBW3FT6XIIhParY4IuEVnQrAnYoP66iHLlQW400vs8JxrzCsUBy6/tAL27nGTxW1PRByN/F p+EuR8/cHPCn78i+gqPcU69+FnTFQmIAmIGWxJW9W9PUNUMJ/xkcKiKYSzW6OUcOjfajXyOGQzlnq blIoI3VCCkpddI9BFHSpOBOgN3uQmhRTrsUD9H1Q313r2s2/FIee8A8mxv0y5PBJ1RWxYMWazTjlO pSPscoqQ5XiLQvwZTBiUuCYQb6eTEAShTADJNaYpgqA2agEPkSh47NgE/UrP8vH8BZORQUCUdh1ZF wgwVsdr9xiDjau394nzyA9rFVoRCc3hi5A4Rt85RPteFggPL0LKr0qB97kJhPN1yRNC7mstWvLSlZ 4cLCFR6mdcjyhRw9e5E6TjjLM44LnWOJfEwZNHaWFD8gVkndxSVn9iXkHOijY5jNlVMhkIujQRajt sEqzWOAkGhY9ZKasfhgTZaqRYMqrCZ+CyVdsxzgAFoeuO4/12FF8f1JunprZPs+xWCUG5tn5RnC24 uffntWvblkQmAUh+/dj5d1Eo3IsizF2sBsapuBhc4=; Received: from chkno by chkno.net with local (Exim 4.91) (envelope-from ) id 1gY4ry-0001Yd-Tb for bug-coreutils@gnu.org; Sat, 15 Dec 2018 00:00:18 -0800 Date: Sat, 15 Dec 2018 00:00:18 -0800 From: scottworley@scottworley.com To: bug-coreutils@gnu.org Subject: Allow split to write into FIFOs Message-ID: <20181215080018.GF703@chkno.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="fUYQa+Pmc3FrFX/N" Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 15 Dec 2018 10:32:53 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.1 (-----) --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline TL;DR: Attached: Patch to allow split to write into FIFOs. Currently, split fails when its output files are FIFOs because FIFOs cannot be ftruncate()d. Split exits with this error message: split: xaa: error truncating: Invalid argument The attached patch causes split to only attempt the ftruncate when its output is a regular file. --fUYQa+Pmc3FrFX/N Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="coreutils-split-into-fifos.patch" --- coreutils-8.29/src/split.c.orig 2017-09-20 01:17:21.000000000 +0000 +++ coreutils-8.29/src/split.c 2018-12-15 07:37:31.000000000 +0000 @@ -470,7 +470,7 @@ if (SAME_INODE (in_stat_buf, out_stat_buf)) die (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"), quoteaf (name)); - if (ftruncate (fd, 0) != 0) + if (S_ISREG(out_stat_buf.st_mode) && ftruncate (fd, 0) != 0) die (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name)); return fd; --- coreutils-8.29/Makefile.in.orig 2017-12-27 18:25:58.000000000 +0000 +++ coreutils-8.29/Makefile.in 2018-12-15 07:03:11.000000000 +0000 @@ -5491,6 +5491,7 @@ tests/split/additional-suffix.sh \ tests/split/b-chunk.sh \ tests/split/fail.sh \ + tests/split/fifo.sh \ tests/split/lines.sh \ tests/split/line-bytes.sh \ tests/split/l-chunk.sh \ --- /dev/null 2018-08-27 15:55:28.530128552 +0000 +++ coreutils-8.29/tests/split/fifo.sh 2018-12-15 07:36:50.000000000 +0000 @@ -0,0 +1,47 @@ +#!/bin/sh +# Verify that output can be written to FIFOs + +# Copyright (C) 2002-2017 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ split + +printf '1\n2\n3\n' > in || framework_failure_ + +cat <<\EOF > exp-1 +1 +2 +EOF +cat <<\EOF > exp-2 +3 +EOF + +mkfifo xaa xab || framework_failure_ + +split --lines=2 in > out & +split_pid=$! + +for f in xaa xab;do + timeout 10 cat "$f" > "$f-data" +done + +wait "$split_pid" || fail=1 + +compare exp-1 xaa-data || fail=1 +compare exp-2 xab-data || fail=1 +test -f xac && fail=1 + +Exit $fail --fUYQa+Pmc3FrFX/N-- ------------=_1544905262-18919-1-- From unknown Tue Sep 09 22:28:54 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33761: Allow split to write into FIFOs Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sat, 15 Dec 2018 20:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33761 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: scottworley@scottworley.com, 33761-done@debbugs.gnu.org Received: via spool by 33761-done@debbugs.gnu.org id=D33761.154490665721220 (code D ref 33761); Sat, 15 Dec 2018 20:45:02 +0000 Received: (at 33761-done) by debbugs.gnu.org; 15 Dec 2018 20:44:17 +0000 Received: from localhost ([127.0.0.1]:49710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYGnI-0005WC-Ry for submit@debbugs.gnu.org; Sat, 15 Dec 2018 15:44:17 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:49630) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYGnH-0005Vz-HZ for 33761-done@debbugs.gnu.org; Sat, 15 Dec 2018 15:44:15 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7809716098A; Sat, 15 Dec 2018 12:44:09 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 6nL9iDp5mgGl; Sat, 15 Dec 2018 12:44:08 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7CB9D16098B; Sat, 15 Dec 2018 12:44:08 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 9yMPNQk6ZICH; Sat, 15 Dec 2018 12:44:08 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 422F6160901; Sat, 15 Dec 2018 12:44:08 -0800 (PST) From: Paul Eggert References: <20181215080018.GF703@chkno.net> <48dcbb21-638a-3f98-4760-3d16a6f71460@cs.ucla.edu> Organization: UCLA Computer Science Department Message-ID: Date: Sat, 15 Dec 2018 12:44:07 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <48dcbb21-638a-3f98-4760-3d16a6f71460@cs.ucla.edu> Content-Type: multipart/mixed; boundary="------------167A4E3C638DBDF687AABDD4" Content-Language: en-US X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------167A4E3C638DBDF687AABDD4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I forgot to add a NEWS item for this, which I fixed by installing the attached. --------------167A4E3C638DBDF687AABDD4 Content-Type: text/x-patch; name="0001-shred-sort-split-add-NEWS-item.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-shred-sort-split-add-NEWS-item.patch" >From c8161ff3e4b50882fde7dc4533004b130a170339 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 15 Dec 2018 12:42:18 -0800 Subject: [PATCH] shred,sort,split: add NEWS item --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index 8c1283549..47eb1ddcc 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,13 @@ GNU coreutils NEWS -*- outline -*- df no longer corrupts displayed multibyte characters on macOS. [bug introduced with coreutils-8.18] + shred, sort, and split no longer falsely report ftruncate errors + when outputting to less-common file types. For example, the shell + command 'sort /dev/null -o /dev/stdout | cat' no longer fails with + an "error truncating" diagnostic. + [bug was introduced with coreutils-8.18 for sort and split, and + (for shared memory objects only) with fileutils-4.1 for shred] + sync no longer fails for write-only file arguments. [bug introduced with argument support to sync in coreutils-8.24] -- 2.17.1 --------------167A4E3C638DBDF687AABDD4-- From unknown Tue Sep 09 22:28:54 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33761: Allow split to write into FIFOs Resent-From: scottworley@scottworley.com Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 16 Dec 2018 00:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33761 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: 33761-done@debbugs.gnu.org Received: via spool by 33761-done@debbugs.gnu.org id=D33761.154491906822920 (code D ref 33761); Sun, 16 Dec 2018 00:12:02 +0000 Received: (at 33761-done) by debbugs.gnu.org; 16 Dec 2018 00:11:08 +0000 Received: from localhost ([127.0.0.1]:49783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYK1T-0005xb-SZ for submit@debbugs.gnu.org; Sat, 15 Dec 2018 19:11:08 -0500 Received: from 75-145-22-45-washington.hfc.comcastbusiness.net ([75.145.22.45]:56904 helo=chkno.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gYK1Q-0005xS-6D for 33761-done@debbugs.gnu.org; Sat, 15 Dec 2018 19:11:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=scottworley.com; s=20181127; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=K5nDexB2J+R9+vzQ7FqQVXtVF4M0MP3AgnVE/hRv6qs=; b=oAjhFXk798PNZkRhYTDBf5A8E nLEOM2U9OCoRVIqJiMXIuYOHMvynESy4cSj2tZpG672TLkc5jd9ZcwTQmHYQn3Dv+cXrlOXhbW73x aT/wSTpUNkssahUZe2DGwa4Pxmj2mdF/MyECDg/DmKkZRJPVOEIrrSC05UN7eIHtE5RA6Te8TKS4u 9J8HGsA/VVk04e4wFoPHVmYB/VBrlc9X5WOOVIgHCDH/4lyJzxGDM2GG+i26ekjCDHQqDzbYBXghK fz03+DuvmO+98PEr5kHHOBSU7ULMDZM/CtAHXesk3p2TUGOB+MMri32vSqHy18klFhgcKLTuQWlRj Sz1QaXkiz2L7Le/au+6ZP44lH6CUrsf6dAcTr5jiN2/PrNbkilt6NAriTXfnurR8R04UYtzwJW5eB wqAhy2RHps1VQQg1m/9K1wnz6sg3T9fgBnPyJ9tW0lmBHHgjfh4Qv+JfyfZZwqQ3cMki/4P4LqSr1 IDVj4UqER82ggM47+6HKhuSwmBmjIDuifyhVwQDSkzDoqayDubD3mmBnMxJ+QFBIe/BwWLlVgLoxm 8FjOLc2Zw35LhfUvrOOA/LOdou3S/ymCfmykc/IcbdmJ2hQ4I4vxhC/gvofG5iXKk35wBYCcpHC9j tyvYHu8GKlE5gIobMsfYbRPuP56SOfpaT7Pg2FtLqY=; Received: from chkno by chkno.net with local (Exim 4.91) (envelope-from ) id 1gYK1P-0007V1-1Q; Sat, 15 Dec 2018 16:11:03 -0800 Date: Sat, 15 Dec 2018 16:11:03 -0800 From: scottworley@scottworley.com Message-ID: <20181216001102.GH703@chkno.net> References: <20181215080018.GF703@chkno.net> <48dcbb21-638a-3f98-4760-3d16a6f71460@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48dcbb21-638a-3f98-4760-3d16a6f71460@cs.ucla.edu> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Score: 0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On Sat, Dec 15, 2018 at 12:20:00PM -0800, Paul Eggert wrote: > Thanks also for the test case. To install that I'll need a copyright assignment > form signed; can you do that for us? If so, please let me know and I'll get the > paperwork ball rolling for you. Yes, I can do copyright assignment. I sent an email to assign@gnu.org per the directions at https://www.gnu.org/software/gnulib/Copyright/request-assign.future , as referenced from https://git.savannah.gnu.org/cgit/coreutils.git/plain/HACKING , as referenced from https://www.gnu.org/software/coreutils/ Thanks!