From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25255 invoked by alias); 21 Jan 2016 19:13:25 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37724 Received: (qmail 11981 invoked from network); 21 Jan 2016 19:13:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=BXADgBWKJ/kpaVVTA3rDzITCwEC7bReQ3O7pWA5LMxs=; b=Et+fTovgYCTBhpJ4CkZW0UCsDB4DxvroJlBTtOaHq62E0wTtWNN3zdxi6LCGcV0OLI W8ZiEsVLG9l4NLn/HnKVM11fb2XlobNPJFp3DU83L9dti2F8GQkpiA6ZnSwbR0OLokdI 3ppkyCODozcJRaeZjwEcqA0eMpJTnIM4p6/p2+pwwbz7Zr/YBWyzl6T5AL1M98Orb9od lleksyrx2S/XhQs67oPg9Tm+t5kCDqO8q3F6aw/dG/pPf9NDZT9WZ9Tb0qWYEyIhIEJ2 6wti7JJtxioAcriK/TmE3J8ABXgh/kCqpsaOpSj0jj6leZyKNIKxgAkbTT1bD8ZFz/nu KQsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=BXADgBWKJ/kpaVVTA3rDzITCwEC7bReQ3O7pWA5LMxs=; b=IyZV4e0eCJUyBeojBzm+ayoYldfuRE4Luy0WRMEsmdQJr27bKFl4s67hzQK0ljwaPb 4z1xvOFyRbwSXlr1D8N6Lsbj9dGMA/wbN+3oMROnsWGhrOvNfvGGqSFHRm/soJu5HDQm sDjsP6HfCW/iKFZhRgSnLg000Au9t1pDHNfHVqgHjp3Hpk/6Ka6b9r5kknWQinacL6tU q8TBH5J3lLlIQCFPijSa3iuCH60zjtH5XSDhgC3ABE4Cw14NFDFZ8N6a3hBseXd2GYJn nlxrsgu6xFI5XnYM7XcUeF4gn8aGeo5N9yiAcg4EEzTQuIHJonl1H1FSSnyOJ6iny0FI zc2A== X-Gm-Message-State: ALoCoQlDEoC4PYtirTnwggTs5MmsJ/LBAPhRBcMED6qYFzSolwNiH78DQUIBhSvadQzn3/fajNkckHgn4Tux2Oc0SOIhfz5GOA== X-Received: by 10.98.70.17 with SMTP id t17mr62505392pfa.107.1453403602899; Thu, 21 Jan 2016 11:13:22 -0800 (PST) From: Bart Schaefer Message-Id: <160121111355.ZM25640@torch.brasslantern.com> Date: Thu, 21 Jan 2016 11:13:55 -0800 In-Reply-To: <20160121135120.GC21104@cventin.lip.ens-lyon.fr> Comments: In reply to Vincent Lefevre "Re: prompt update and TRAPCHLD" (Jan 21, 2:51pm) References: <20160114171631.GC12351@cventin.lip.ens-lyon.fr> <160114185941.ZM18307@torch.brasslantern.com> <20160121135120.GC21104@cventin.lip.ens-lyon.fr> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: prompt update and TRAPCHLD MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jan 21, 2:51pm, Vincent Lefevre wrote: } Subject: Re: prompt update and TRAPCHLD } } On 2016-01-14 18:59:41 -0800, Bart Schaefer wrote: } > The right thing is to explicitly tell ZLE to update the prompt: } > } > TRAPCHLD() { } > psvar[1]=$RANDOM } > [[ -o zle ]] && zle reset-prompt } > } } } There's something wrong with it: } } TRAPCHLD:zle: widgets can only be called when ZLE is active Oops, that should be zle && zle reset-prompt } > Or perhaps your complaint is that the TRAP* function should run sooner? } } I think I was surprised when doing some tests. I thought that there } was some race condition in my code because the TRAPCHLD was run too } soon, but that's the opposite! So, the problem is something else. The rule actually is that traps are executed as early as it is "safe" to do so (memory management, etc.), and one of those times is immediately before another command is going to be run; so the trap could execute for example at any time during your precmd function, or during zle-line-init, etc. So in that sense yes, there is a race condition.