From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 112 invoked by alias); 1 Apr 2011 14:14:56 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15911 Received: (qmail 10193 invoked from network); 1 Apr 2011 14:14:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110401071434.ZM3403@torch.brasslantern.com> Date: Fri, 01 Apr 2011 07:14:32 -0700 In-reply-to: <19DA6B3D-8C10-4743-BA15-39EDAE324342@biskalar.de> Comments: In reply to Sebastian Stark "signal handling via ssh" (Apr 1, 11:27am) References: <19DA6B3D-8C10-4743-BA15-39EDAE324342@biskalar.de> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users Subject: Re: signal handling via ssh MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Apr 1, 11:27am, Sebastian Stark wrote: } } ssh -t $server "less +F /var/log/syslog; exec \$SHELL -l" } } and press '^C' I'm logged off from $server. The '^C' does not seem to } go through to only the less process. } } How can I achieve something like the above but such that ^C does not } end the ssh connection? The ^C is a tty-driver interrupt, which means it's sent to the "process group leader" which controls the pseudo-tty allocated by ssh -t. In this example the group leader is the entire shell process that has been invoked to run those two commands in sequence. So what you need to do is stop the group leader from reacting to the signal while allowing "less" to do so. You can do the first with the trap command, but that ignores the signal in all sub-processes as well, so you have to restore the signal handling in a new process created explicitly for that purpose. It all comes out like this: ssh -t $server "trap '' INT; \ (trap - INT && exec less +F /var/log/syslog); \ exec \$SHELL -l" --