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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15383 invoked from network); 28 Sep 2021 19:51:41 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Sep 2021 19:51:41 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1632858701; b=BfWOkOC/hk1mcOz3dl1I97H65hIV3GW1sSeuCsPE0/PwoD3PMp62+8Vbm6gEP77izntEFJBKrE MPGxqHS6raGCrM7j5azCZ3i3Qj3/omoDN5Jml/Hu0EQQJHG2CzmNJBkkHcBHhRiuiFIKD6IQC4 I1pV+XuM4eST5Ygy+Hcv0vWWfRc4Ckd+e6TMKk5naioLgBCs20MgItJx/KSuYELbfKns+6hM5k RQlfHmkxRqr4qywuqCb6BU4nwKr9HdmjspXTlhoBGX7bq7tQL9sZDpScLguM/iqPI/F/g992lj yyq3A5xPXJXL8IuAvZlIgAddwws6IKqmP5QoMubRWOjqhg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f45.google.com) smtp.remote-ip=209.85.166.45; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1632858701; bh=NqHO+st6/E0nEgBMZkfkXgplcBHipJoCelpzC1kw6j8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=M7hEq19nZ6ZhppGm1uy/vRfigjecYZW16Tw85utpbNsI7wNiWsL2WUfwJWTdfXmX1cWYLYwyNi HMgALM8AeuXq6zEh5g+ySRwvcQgGhF4uWJC+sleEaTpz0mppL+zxqGzgtu064pWuxBaIzYH42t 9woWuMMGpxhUmRP4u/Y5V/YFyVlRo28+eNV7sHQowKs8hh2E7GRrzVuyJ+d/d+x0hK31eK97uN g3MwyW0n5tsiOCdGhrZm5rsyjfR3Zc4yfKgaJJK8h7wX3O7pyVZm/qYdWhcSZ7jHbgDyeJ1pTa 5WyuN143oI82gVMQFoPVoObNmv10T93saam8JvQKCOC2oA==; 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:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=RKqfPQTzEmLEHjsMkdI3pw8MkwMRkgMmpCjpbtNRmus=; b=szvmZtoIkcZT16t7/y5+A5l0Df bNzq6Ih4iQ3wjvUR4Tz0UaZyVzNnX5LUOHKmkw6/wspZIB0ZoL04Pv5Ark59dXpRPpN0HSEp5FE8P hImz1WOqrctOTa+nMEHAt+JqJKuxyh1x+3GHE8e8uPbu21szhb5Gwg5U64RlxVoAQXQQOPBfCZEyw pIBqMDCnMOMzU4FQrQPPPZtiFEQDesCcjnAnPpPL0Wg0vPLjhALWMC+kVvJcnbZI4HqBFE9AWLz7s vgEwDYAtqec9Hu5aF8kWh4m4N2VKASUWfqt7CFwo7dJQQ2Blc/amd4q0OJxsnufwuSXUH40y5YoPd 9NDg+smg==; Received: from authenticated user by zero.zsh.org with local id 1mVJ8e-000N9u-UG; Tue, 28 Sep 2021 19:51:41 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f45.google.com) smtp.remote-ip=209.85.166.45; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-io1-f45.google.com ([209.85.166.45]:35423) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mVJ7s-000MSN-P5; Tue, 28 Sep 2021 19:50:53 +0000 Received: by mail-io1-f45.google.com with SMTP id b78so121472iof.2 for ; Tue, 28 Sep 2021 12:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=RKqfPQTzEmLEHjsMkdI3pw8MkwMRkgMmpCjpbtNRmus=; b=oq1zoAQWTzKHNLmP4jNfsfVeN67RgXI6KdHTsKDxay2U5sgFJ1xNGY9vwL1rpCYmCY NT9EqgtAI+MJSv2+oCA8Sf4Tn5DnVBnq77o5lFWu26kYxDgvksDOQVyY4lP4VupEI88L +ahza2kYTL6S1LEcB2UVLCDe0gQXyh/Ns6qqMbHU2bLLeTrY3o7Je195aFRENoH+fijG h85zUJAEfB5mXN+6MrzcukD7FqLi3JQUyDKjxv78OnKvhnIl42OQhweGTnSXU5Grd/YH DNa0OjMeBMMH7Pt8zr+EyNDlpicT83IwOg0kjhxmYNEbWHJeKtPXW79wH4Pg4ZWWU7cn 5deA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=RKqfPQTzEmLEHjsMkdI3pw8MkwMRkgMmpCjpbtNRmus=; b=vgbubrj26sFrYW8dE4/odgNiOKB2cLyI3j7PQy4TtCAzp9iKM0Jj1wdlW0Ins94gV5 J0WU9RiBtML5kw4NzOgmIaeVxHPup4qSDnnwGtrT5XWAHWjsrlTT2/WwccCHuhnE3aE+ R8czJYqQrfvybevMuTuFGwVbdq1o6T9oFKFqy+FM6RnvjaOkSNdGvCmujy+sYdNLZSMB pXjjDP7PEBXWgJ0zg7baChYsc6ZVSCFNJlgNceh7aUGzmjBLySMJsg0Mr4FWlhglx1ih AQlL70PkkLbD5+9wezzBc+OihoFQX7Nr8GIPyHS7OxbkrwlwVzJK5D3Hpnj0g8Xcl5ST OgRA== X-Gm-Message-State: AOAM531zpVMuLp/D4QINYOP5sNeTd341P8JVg0W9GPnfY1LcjH7OMlY4 RYlrROdxH0rpj19R0EZOdYqFc4rDkXi2YxLrTJ8= X-Google-Smtp-Source: ABdhPJxMLNkRW/lkkm870jympzO5l5UT12nfnTpWSTpf/2qOnt13kfoGkFVM8YB1ComUpUcuCoR5LE5YxEsAVf9Zedo= X-Received: by 2002:a5d:8788:: with SMTP id f8mr3707025ion.193.1632858651466; Tue, 28 Sep 2021 12:50:51 -0700 (PDT) MIME-Version: 1.0 References: <20210927233143.GA16620@gmx.de> In-Reply-To: <20210927233143.GA16620@gmx.de> From: Pier Paolo Grassi Date: Tue, 28 Sep 2021 21:50:14 +0200 Message-ID: Subject: Re: less with subprocess To: dominik.vogt@gmx.de, Zsh-Users List Content-Type: multipart/alternative; boundary="000000000000e3a44d05cd138728" X-Seq: 27161 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: --000000000000e3a44d05cd138728 Content-Type: text/plain; charset="UTF-8" Hello: >2) You want "ctrl-c" to stop less from reading input and go into > "view" mode, then press "F" to go back to "listening" mode? If > so, what are these experiments with "SIGPIPE" trying to do? this I have no problem obtaining with: less -f <(long lived find command) >1) less does not react to SIGINT before it receives any input. > Actually, less (v487) does not react to SIGINT before it > receives a full screen of input. Yes I was looking for help about this issue. I understand now from yesterday's experiments and the help from the ml that less is the reason I can't kill the pipe when I press ctrl-c, since it eats the sigint before it has a full screen of input, as you pointed out. I would have liked to be able to trap the sigint and send a sigpipe to the session, thus killing both less and the long lived no-ouput-still find command. But it seems to me this is unachievable, since less must be the foreground process, and thus, if it eats the sigint, nothing can be done about it. One experiment seemed for a moment a good solution, using unbuffer from expect package on less, but the less loses the ability to process interactive input. So it seems that ctrl-z, kill % is the only solution that can be applied when less "hangs" waiting for more input and ignores ctrl-c, without resorting to using kill from other terminals. The solution mentioned with =() I do use sometimes, but this was more of a "what about doing everything in memory" challenge; about the solutions with a pipe instead of process substitution I already investigated and I wasn't able to make it work, in particular I wasn't able to make the solutions with the trap on the first command to work, such as: ( trap "" INT; sleep 10; i=1; while true; do echo $i; i=$[i+1]; sleep 1; done ) | less and the likes, I still get the lines 1--1...skipping... output and the need to use ctrl-z Pier Paolo Grassi Il giorno mar 28 set 2021 alle ore 01:34 Dominik Vogt ha scritto: > On Tue, Sep 28, 2021 at 12:57:02AM +0200, Pier Paolo Grassi wrote: > > I am trying some variations based on suggestions from the page Roman > linked: > > > > (trap 'kill -PIPE 0' INT; less -f -+F <(eval "sleep 100" )) > > /proc/self/fd/11 lines 1--1...skipping... > > /proc/self/fd/11 lines 1--1...skipping... > > /proc/self/fd/11 lines 1--1...skipping... > > /proc/self/fd/11 lines 1--1...skipping... > > /proc/self/fd/11 lines 1--1...skipping... > > /proc/self/fd/11 lines 1--1...skipping... > > > > the "skipping lines" is what is printed, I assume by less, when I press > > ctrl-c > > I can confirm that using ctrl-z and kill % is able to successfully get > rid > > of the process, but it seems kind of an emergency measure to me, not > what I > > would like to be my routine. > > It seems to me that less is eating the ctrl-c, so the trap is never > called, > > It's still not clear to me what you're trying to accomplish. You > mentioned two issues: > > 1) less does not react to SIGINT before it receives any input. > Actually, less (v487) does not react to SIGINT before it > receives a full screen of input. A workaround is to print some > dummy input before the real command. Something like > > less -f <( repeat $LINES; echo ""; ls -lR / ) > > 2) You want "ctrl-c" to stop less from reading input and go into > "view" mode, then press "F" to go back to "listening" mode? If > so, what are these experiments with "SIGPIPE" trying to do? > > If you want less to work on the command output like it would > work on a growing file, why don't you just *write* that output > to a file and run less on that? > > alias -g LF="> $HOME/tmp/less-input.$$ & less > $HOME/tmp/less-input.$$; kill %; rm $HOME/tmp/less-input.$$" > > Run it with > > ls -lR / 2> /dev/null LF > ^^^^ > > The global alias saves you the effort of typing all that stuff > with the tempfile and less after the command. > > (You really want to use a private path for the tempfiles > because the alias would be vulnerable to symlink attacks when used > in a publicly writeable directory.) > > Ciao > > Dominik ^_^ ^_^ > > -- > > Dominik Vogt > > --000000000000e3a44d05cd138728 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello:

>2) You want "ctrl-c&quo= t; to stop less from reading input and go into
>=C2=A0 "view&quo= t; mode, then press "F" to go back to "listening" mode?= =C2=A0 If
> so, what are these experiments with "SIGPIPE" t= rying to do?

this I have no problem obtaining = with:

less -f <(long lived find command)
<= div>
>1) less does not react to SIGINT before it receives = any input.
>=C2=A0 Actually, less (v487) does not react to SIGINT bef= ore it
>=C2=A0 receives a full screen of input.

Yes I was looking for help about this issue. I understand now from = yesterday's experiments=C2=A0and the help from the ml that less is the = reason I can't kill the pipe when I press ctrl-c, since it eats the sig= int before it has a full screen of input, as you pointed=C2=A0out. I would = have liked to be able to trap the sigint and send a sigpipe to the session,= thus killing both less and the long lived no-ouput-still=C2=A0find command= . But it seems to me this is unachievable, since less must be the foregroun= d process, and=C2=A0 thus, if it eats the sigint, nothing can be done about= it.
One experiment seemed for a moment a good solution, using un= buffer from expect package on less, but the less loses the ability to proce= ss interactive input.
So it seems that ctrl-z, kill % is the only= solution that can be applied when less "hangs" waiting for more = input and ignores ctrl-c, without resorting to using kill from other=C2=A0t= erminals.
The solution mentioned with =3D() I do use sometimes, b= ut this was more of a "what about doing everything in memory" cha= llenge; about=C2=A0the solutions with a pipe instead of process substitutio= n I already investigated and I wasn't able to make it work, in particul= ar I wasn't able to make the solutions with the trap on the first comma= nd to work, such as:

( trap "" INT; sleep 10; i=3D1; while true; do echo $i; i= =3D$[i+1]; sleep 1; done ) | less

and= the likes, I still get the=C2=A0
lines 1--1...skipping...=

output and the need to use ctrl-z

Pier Paolo Grassi
=


Il giorno mar 28 set 2021 alle ore 01:34 Dominik Vogt= <dominik.vogt@gmx.de> ha = scritto:
On Tue,= Sep 28, 2021 at 12:57:02AM +0200, Pier Paolo Grassi wrote:
> I am trying some variations based on suggestions from the page Roman l= inked:
>
> (trap 'kill -PIPE 0' INT; less -f -+F <(eval "sleep 10= 0" ))
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
> /proc/self/fd/11 lines 1--1...skipping...
>
> the "skipping lines" is what is printed, I assume by less, w= hen I press
> ctrl-c
> I can confirm that using ctrl-z and kill % is able to successfully get= rid
> of the process, but it seems kind of an emergency measure to me, not w= hat I
> would like to be my routine.
> It seems to me that less is eating the ctrl-c, so the trap is never ca= lled,

It's still not clear to me what you're trying to accomplish.=C2=A0 = You
mentioned two issues:

1) less does not react to SIGINT before it receives any input.
=C2=A0 =C2=A0Actually, less (v487) does not react to SIGINT before it
=C2=A0 =C2=A0receives a full screen of input.=C2=A0 A workaround is to prin= t some
=C2=A0 =C2=A0dummy input before the real command.=C2=A0 Something like

=C2=A0 =C2=A0 =C2=A0less -f <( repeat $LINES; echo ""; ls -lR = / )

2) You want "ctrl-c" to stop less from reading input and go into<= br> =C2=A0 =C2=A0"view" mode, then press "F" to go back to = "listening" mode?=C2=A0 If
=C2=A0 =C2=A0so, what are these experiments with "SIGPIPE" trying= to do?

=C2=A0 =C2=A0If you want less to work on the command output like it would =C2=A0 =C2=A0work on a growing file, why don't you just *write* that ou= tput
=C2=A0 =C2=A0to a file and run less on that?

=C2=A0 =C2=A0 =C2=A0alias -g LF=3D"> $HOME/tmp/less-input.$$ & = less $HOME/tmp/less-input.$$; kill %; rm $HOME/tmp/less-input.$$"

=C2=A0 =C2=A0Run it with

=C2=A0 =C2=A0 =C2=A0ls -lR / 2> /dev/null LF
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 ^^^^

=C2=A0 =C2=A0The global alias saves you the effort of typing all that stuff=
=C2=A0 =C2=A0with the tempfile and less after the command.

=C2=A0 =C2=A0(You really want to use a private path for the tempfiles
=C2=A0 =C2=A0because the alias would be vulnerable to symlink attacks when = used
=C2=A0 =C2=A0in a publicly writeable directory.)

Ciao

Dominik ^_^=C2=A0 ^_^

--

Dominik Vogt

--000000000000e3a44d05cd138728--