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, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8631 invoked from network); 7 Sep 2022 22:21:24 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Sep 2022 22:21:24 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1662589284; b=K44nBliQ6H4Pi5IocXzrHIuv/LHjs9etyBt0CCdsd0NGIWnAy5kdFCg/guHOyI3ZADbx6vWr17 E3EdLVpiF8k5KXg/E2vBeCmOUm5YXKsewSu6X1jQVp+krUWLM3CsVzigcN5osNjk7oYjN6KX75 OpTOLcX9/jG4CI+ARGYZ3SbbmRh+Z38pmCw/UyK+Qh1mZOWNdeq+Yhex22J19GNWhb7xVRNx/Z F9U6ueo/qmoSXfV4GamBu/c3n3jdfwLwDMKPLHb5KPHhPwIJIwPh+3BRdv9Tw/pDZ3t07eAeX2 ODIXB1rMLCfjcboYlsYSku331LQB5B3W9NHxhqmHssCxgA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f52.google.com) smtp.remote-ip=209.85.208.52; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1662589284; bh=2d4Km/J3oRUQXrPRBmyuWw4DBYxnno9TC+G2AYMd7VI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=B2NVWplKMuYyqOl/sT55HAgwU4DRj5gX7sYuAuE5B64NTILZ90sA3IJ8zpMo6KmvVjfNsyh+/U 50RKeWEP6glrTob7vowftlFAi9BNzl9vEYLn7Si4vL7GQc/MT9w/yTCpgoDAJ4WwEQL6Xmiifk D2NgdWuoampR8sFxDYIexr2xLWtSkriJ4PHT5SeEcEoV6puLLg9PQPxGcraAnprby7EfdiX+jp enUDOiQTLj++Tz9ENaxkW5lAEEPeyluW0I3IxeXHBPYZkSFfr/BNzIa1A4KUtIvO1iIDTEoVVv diQQa0Z+yPTRdKrkjUl0hFzsILYMlq3rIdrhnnaqVd+opQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=HhjLTxMvOag3DCmGbO+acLsDqoNa0PhnmqaQq7L75vw=; b=q3BZioxUAmyetrgIDUQLpVYx/X W0NRjcaAhG0n6evU0j2y0f2Wcq/8+EshR7V4BtS9bajFzwkp050yRR4TKwPE3r4s7msU4qTGc4t8z MsrDcCz9OhP7BIv390vz2ecEjGb3wzawAQ7/nRzXTcDKfez3kdmDhuRxE/NFHjk6Rt2wTfvHnkwFY EahYVBmZXRZ+XnxTkvauoDfsB7NXYtv47BbIaE3MAXm4PQ8+KKLFGC0z6yfBvJwYplOhgjyJKop2c By3uVXDBhmoYFmRLgrjLKr0oaMlRDQg2RfZIivmM75NHFePLnnYomV/qFMS7nxFYte9SFocbJP80k KvrSJiww==; Received: from authenticated user by zero.zsh.org with local id 1oW3QB-0003qS-D6; Wed, 07 Sep 2022 22:21:23 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f52.google.com) smtp.remote-ip=209.85.208.52; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ed1-f52.google.com ([209.85.208.52]:39556) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oW3Pr-0003Vn-CY; Wed, 07 Sep 2022 22:21:04 +0000 Received: by mail-ed1-f52.google.com with SMTP id z8so21682550edb.6 for ; Wed, 07 Sep 2022 15:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=HhjLTxMvOag3DCmGbO+acLsDqoNa0PhnmqaQq7L75vw=; b=MCxWbaCwOJqGJ7foqdiT5O6Op25xUvyVRWq5tPe3fUZKcG+AoTCqN6r17TrtbhPHTz ViDfGZolnnnQA1btOPsJeQUm6lYsYAOmdjiTVgjGoMqFvMMba/LTQa40I10y5r/zc1PZ Opuwb4Jicrx1/Ll2kxCC+vJGgks3dMLvZv1CVY9rE2Endd0ETn3x016GIDSiR/ewObaw Ip236Zg7EA9izac0HXWhKX5G/zRzbs5OW++ddKX0gS0ePkWlyfpND3pmO0rjNu/sC3Gs YpnIvmOMhvLqx5/wsin+pTkAyqnssLlOkCYnnacEfJZ7eyXfaq32/wz85hO5Ecdl91lC 1Lxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=HhjLTxMvOag3DCmGbO+acLsDqoNa0PhnmqaQq7L75vw=; b=50P7gSXG+muNzzhNJau50uwUwi4DL5/yrpwbdrkVJ2u9c8Bid2oheIHb9qqjd+A0Wc 6T22mHGDNHpou+KGsytTloQ86YxCwiyEhBuEUr+0Wg5yR/G8FiUHJsoAVwaetDZ6xuQd 9K2asBleWV0vP88tciiUg2MNyWlQDUjwRCjlzxVCE9h7uCY4EqjYPhfZTT590NIkQHEC bVYdSUyHiwItaHrioNGs4jaDVxGG0zIVHlQG+IVn6luGwCqbJjTT0MYea+lqsj4ZuasH wU3Kb+vCy/rLLx+dh5nmf81AhgcX7pss7JJvEXu+fSPmba+w09tq3i4RRCid2gBYvVV/ WbhQ== X-Gm-Message-State: ACgBeo22S/Ma1QBw83dBckYgT9tuECrikPokYgTSEG8cRm27EqKt7kZd sA4+yORkf06VLs1+hPZfT201OBAHSCNQ65SF7i9TfyqMMrzBig== X-Google-Smtp-Source: AA6agR7geK4oobGP4G26+iLpRPypxOc5ED7U0HKxfFM4DaDFBkzwsZL7MSD8Yw3FTyzuCJbIRIeNXtOBELyvEPAyJfQ= X-Received: by 2002:a05:6402:268b:b0:446:381d:7b45 with SMTP id w11-20020a056402268b00b00446381d7b45mr4718273edd.372.1662589262971; Wed, 07 Sep 2022 15:21:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Wed, 7 Sep 2022 15:20:51 -0700 Message-ID: Subject: Re: Unexpected infinite loop with xclip To: =?UTF-8?Q?Micha=C3=ABl_Cadilhac?= Cc: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="0000000000006d5bfb05e81dba13" X-Seq: 50614 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: --0000000000006d5bfb05e81dba13 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Sep 7, 2022 at 2:44 PM Micha=C3=ABl Cadilhac wrote: > $ while :; do read; echo | xclip; echo loop; done > Bash executes the left side of a pipeline in the current shell and the right side in a forked subshell. Zsh does the opposite, which means xclip is a process group leader with access to the terminal. xclip itself then forks and clones a copy which continues running. That copy has control of the terminal, which causes "read" to see an I/O error and immediately fail. You can see read exiting failure if you change the loop to be while :; do read; echo $?; echo | xclip; echo loop; done You're not testing the return value of read, so the shell goes on to the next statement and the effect repeats. Each new xclip causes the previous xclip to exit (cf. xclip -l option) by grabbing the selection, so you never run out of processes. --0000000000006d5bfb05e81dba13 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Sep 7, 2022 at 2:44 PM Micha=C3= =ABl Cadilhac <michael@cadilhac= .name> wrote:
$ while :; do read; echo | xclip; echo loo= p; done

Bash executes the left side of a pipeline = in the current shell and the right side in a forked subshell.=C2=A0 Zsh doe= s the opposite, which means xclip is a process group leader with access to = the terminal.

xclip itself then forks and clon= es a copy which continues running.=C2=A0 That copy has control of the termi= nal, which causes "read" to see an I/O error and immediately fail= .=C2=A0 You can see read exiting failure if you change the loop to be
=
=C2=A0=C2=A0=C2=A0 while :; do read; echo $?; echo | xclip; echo loop;= done
=C2=A0
You're not testing the return value of= read, so the shell goes on to the next statement and the effect repeats.= =C2=A0 Each new xclip causes the previous xclip to exit (cf. xclip -l optio= n) by grabbing the selection, so you never run out of processes.
<= br>
--0000000000006d5bfb05e81dba13--