From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29550 invoked from network); 28 May 2021 20:01:57 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 May 2021 20:01:57 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1622232117; b=00T7Xo9MKM8dTvLzvqiRBWcmW5HD1fEa9ejBTiFL6Xi28kfHBnBr+pJg4SiVGHKd8EiT4rsewi QCcKzqEDlSZnqqq4BzYi+ZkSwqHVst4elpB36Udcg2okurh/92e3vuRD4RFAGa2VukPGua+yq2 c40aGXCgvuAl5q5htt/7/5pqibuKPIFJh5d2B6NX5TXYreA21HN2U3UCE9jP+HHqjTFZMDe5bM oueytmjJVfLBmmchWDPuDh3D3xCYxN51iEral0NVkvsu51qseMfJg8KI0FBnXb+osMdmESSX8H ePvadxIZh2iL24ywpcbsG30cJxoQPEIxTeNHa9uBhd+8ig==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay6-d.mail.gandi.net) smtp.remote-ip=217.70.183.198; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1622232117; bh=+3RXvoACNrdRIEbOOm3onWWqpbqLWGr7eAqzv8ejPno=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature; b=Hjp+UgZ2mScFmvzKiQXAAiljN0FTjGQcItTh0GFDK1am11aFmJ9kpfVSz9S3YHj8VUlY+R7RAe cTQL5fxea0kSwIVsml3+C80aos9hAUyorfPOff84sQZhCyDYrqmuW1Hm+BdRKcZJGZHa/O/wAQ tunNAKstlqNqgedyckG6D+T4dFlUxHvH5QZR0QvoGnoF6RtTLadBctBhCKaSpIMu6wUPAdW50N HYN4wTGVl071WcBjCUUgpExhpYvnd5qgCOKsCuFrgvT1HFdoZzokcD3ZeVRCJjEOZm1tRvdf/9 9HlYg/894soGEZ9wq7/hUwTfUjBolbTQ/voB0ig+nTCagw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=zQ2J5YOC+UsMImUNE3R+M8mWUKzk+yA8qb7CLKntin0=; b=Hzi4/hQP1EhuWGBEwP2AIBoRaS uoqIWcgnsWW1NybtiCnmSB+nqM5g2zAvyYEjX54xZKnuaJY69W5DDTFt2RLm3ToPQasls1lWwPEll Ql+LvbOW+kR2tsnXGcdDSzKncBeqwI9YKSAFXcUjv3xmRCZLXwFvIctarcvhw65ebpeReoPuGccKB qtTMYMPAuyutcyYxF1yqH+CXygLSlOH/p2j1izg8dylXyty6LSqvNIrzw75Q2yNA6fXc6H/CekUTk cn121BzOsIUmxlcnHAhPvQsw3OCebSLDjwo3UJe5m0y1tOXB+DRP5ni+KGhQ5p0qO2ze9WX8At/7z H1lfNa+w==; Received: from authenticated user by zero.zsh.org with local id 1lmig8-0008Qt-Pt; Fri, 28 May 2021 20:01:56 +0000 Authentication-Results: zsh.org; iprev=pass (relay6-d.mail.gandi.net) smtp.remote-ip=217.70.183.198; dmarc=none header.from=chazelas.org; arc=none Received: from relay6-d.mail.gandi.net ([217.70.183.198]:53265) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lmifr-00089j-1m; Fri, 28 May 2021 20:01:39 +0000 Received: (Authenticated sender: stephane@chazelas.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id D47A5C0005; Fri, 28 May 2021 20:01:37 +0000 (UTC) Date: Fri, 28 May 2021 21:01:37 +0100 From: Stephane Chazelas To: Samuel Bancal Cc: zsh-workers@zsh.org Subject: Re: broken pipe message with setopt PRINT_EXIT_VALUE Message-ID: <20210528200137.nw35xglpw7j2j4r7@chazelas.org> Mail-Followup-To: Samuel Bancal , zsh-workers@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Seq: 48944 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: 2021-05-28 19:06:00 +0200, Samuel Bancal: [...] > < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c 32; echo; > XKCxcd1QQ8otBre05qUDrvw2GFIdpYNr[1]    97774 broken pipe  tr -dc > _A-Z-a-z-0-9 < /dev/urandom | >        97775 done         head -c 32 [...] Same in yes | head -n 1 In both cases, tr/yes are being killed (with a SIGPIPE) because they're trying to write to a pipe that has no reader. If they weren't killed they would run forever as /dev/urandom is of infinite size and yes never terminates. When a process is killed, it returns a non-zero (failure) exit status to its parent. Which is printed (or rather here the "broken pipe" message corresponding to that death-by-SIGPIPE) because of PRINT_EXIT_VALUE. PRINT_EXIT_VALUE (-1) Print the exit value of programs with non-zero exit status. This is only available at the command line in interactive shells. Even if you ignored SIGPIPE (which in general you don't want to): ~$ (trap '' PIPE; yes) | head -n1 y yes: standard output: Broken pipe zsh: exit 1 ( trap '' PIPE; yes; ) | zsh: done head -n1 You still get a message as this time, yes exit with a failure status because the write it tried to do on that pipe failed with a "EPIPE" error. -- Stephane