From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 43F2C21301 for ; Tue, 23 Apr 2024 17:19:10 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1713885550; b=NsY7Di0mE7Yagg3DRotA6kNwvZKYay6pTAiu3/m7ytIufe6UqhcfrZVUmnYB3H92u50KsRmTL6 8d8/OT6ET6lwDjP9db6wy1Sdfz4uV8jmurbkQnPOOeV+JiNroRczNC0AHBU4wEJvGTa7EO2ob2 mw23Oed1lkstlm4AGbjokg9DBCP5Y9G3hnYtIRLt80Lrs1COyge1omE510N/+4kR6DlzdfsSRV vmJSAurW7AEyOe8TcBkMUiexP9tbruIBzMAAsd0kQDCeS6XdN3Ygo1vJZLlFIiVFm/Q6Z5cO9Y MfD2x06yswX0lklPP39rROvlLN6fTIFVzblsqQAvB4sliQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1713885550; bh=JmjTZVchUETJzYJEC8ED5y2pjXzGYs1zpRQ3+zzN6qY=; 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:To:From:Date:DKIM-Signature; b=HDqCvQGsxXjpjnHEER16jOHYSp15qFyL+KdIlPawvKGqFRnDNQOP3d/2S1yQrAS0RhjlWRrwPd ir0rZQ7Mzgb7a5G3R0nqrj8+i2YKi4NHPhEhg4H/kukgxWgrzGTKRMTV0hYGk+j7QCio3dqK1U x16Dgiy5Sr5xwhWy2++EP1C2uP+D5+MH01rXj8VoMLasgbOMDbLXZW8+Hg2o8mgdOKiuuntLHY rpPLKmnxi0fWFYvpQ1/i0ceOEMi/UMEbaklwYvBpCnZ/5ojE2s5md/PxgkAf2eozVD36aX8r3I L3G65ZjqB5WNxnsznVBYc7pG1uBclpMdTW7yhgXAc/vPQA==; 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:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=iQSXXqIHyTGLRL9TyXPOdpIY0Y1muxO8UDjUf8tQzSo=; b=gjx98dEb8wv3c0d+mLAWK7RyWG XM0jKIs/IjfnH5Ho0LObXwWWmAdd8oFdzeOkE0nv57EW6Ncd3cjJ+U2pd1r0IzDb3tIkXzJNZ+b3O F6TQMNebsQJz+1gHe6UfmuDckwRcg2psjjW0E3vIU5yyAqaIvB/+kNmiyo49U7LQPQCtIfvYCVghZ Yw7aqptQz/e+iUTL3us2kpFvKjQFBtoHUwSuF/9uloHEQLeugVDUVaHoUvdVF/zZ/hpgsMpXF+AFc DZAi6IQUQRfXXMZukVtmn8LZ213CHR/U6k9kyJ1ggOKx+5QiD2wH2iwsbaum1Er3gMeon/02NUiDJ alWfYEfA==; Received: by zero.zsh.org with local id 1rzHvJ-000NaW-BD; Tue, 23 Apr 2024 15:19:09 +0000 Authentication-Results: zsh.org; iprev=pass (joooj.vinc17.net) smtp.remote-ip=155.133.131.76; dmarc=none header.from=vinc17.net; arc=none Received: from joooj.vinc17.net ([155.133.131.76]:54584) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rzHtX-000MjU-5u; Tue, 23 Apr 2024 15:17:20 +0000 Received: from smtp-qaa.vinc17.net (2a02-8428-1b1d-4d01-96a9-491d-7b48-ba31.rev.sfr.net [IPv6:2a02:8428:1b1d:4d01:96a9:491d:7b48:ba31]) by joooj.vinc17.net (Postfix) with ESMTPSA id 26A803CB; Tue, 23 Apr 2024 17:17:18 +0200 (CEST) Received: by qaa.vinc17.org (Postfix, from userid 1000) id DCDA4CA011A; Tue, 23 Apr 2024 17:17:17 +0200 (CEST) Date: Tue, 23 Apr 2024 17:17:17 +0200 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: How to propagate SIGTERM to the foreground job, if any? Message-ID: <20240423151717.GA82287@qaa.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: <20240419190027.GA109916@joooj.vinc17.net> <20240419213225.GA146837@qaa.vinc17.org> <20240421172909.GB146837@qaa.vinc17.org> <20240421174358.GC146837@qaa.vinc17.org> <20240421235909.GD146837@qaa.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.2.13+76 (1f3da810) vl-167818 (2024-04-20) X-Seq: 29859 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: I think that I should start to test with something simpler, with a command like unison -sshcmd ~/scripts/ssh ~/testdir ssh://remote_host/testdir For ~/scripts/ssh, the following works with I type Ctrl-C when ssh-add asks for the passphrase: ------------------------------------------------------------ #!/usr/bin/env zsh unset DISPLAY setopt TRAPS_ASYNC trap 'echo term >&2; kill %1; exit' TERM INT ssh-add file1 file2 file3 echo end... >&2 exit ------------------------------------------------------------ But %1 might not be the right job in more complex cases. BTW, I'm wondering why %1 works, but not %%. Moreover "term" is output twice. Why? The following, based on what you proposed, also works: ------------------------------------------------------------ #!/usr/bin/env zsh unset DISPLAY setopt TRAPS_ASYNC trap 'echo term >&2; kill $e; exit' TERM INT ssh-add file1 file2 file3 & e=$! wait $e echo end... >&2 exit ------------------------------------------------------------ This time, "term" is output 1, 2 or 3 times. But these solutions do not work when ssh-add is in a zsh function, even in a simple case like: f() { ssh-add file1 file2 file3 } and use "f" instead of "ssh-add file1 file2 file3". Is this a bug or is there any reason? On 2024-04-21 17:41:38 -0700, Bart Schaefer wrote: > Try this: > trap 'setopt MONITOR HUP NOCHECKJOBS; exit' TERM This doesn't work at all with the above test. > > ssh-add file1 file2 file3 & > > > > ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory > > ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory > > ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory > > That's ... interesting. The error makes it look like ssh-askpass is > what's not being found, but it's probably choking trying to open a > terminal. I can think of some possible ways to fake it but perhaps > with the above MONITOR tweak it isn't necessary. I don't remember what I did exactly. These errors occur if DISPLAY is set (with my usual wrapper, I unset DISPLAY, so that there may be another cause). -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)