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, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15453 invoked from network); 29 Apr 2022 01:43:55 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Apr 2022 01:43:55 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1651196635; b=RMomMzLJWxia4JXDOKnspQYQkk7Wk+I/HyvqBapI2a6Pw12K7J57SGyj6AUfIhk+MYPIX0NpJK u4oeViekx6SWkCgwZPSpvWeWAtTQXhize60XHtg7gDC6Cal2zzK3kdye380ni3w+5mQsvojJ9T HP0uvOz1xsMqnKSK2mFjVZH8t2DcNJ+cCHNsSayXz/gYMAINPx2e2qx6aMRftuMz4LiIB4UUii EDeTCxlrKgt11MQ9djDtmi8HVa4BSXIxs1YDQcOYdmsXt9X4ZzsSeV4k3D+lgHE5QPPOnmzZNm pBHy5Eutb9wc3SxlVT7SJOegNt4byYf0qnF2zrty4R3Zng==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; 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=1651196635; bh=62GRlkGYwlbZ0DcAH8XBljezqX9a594oBkphyA6fJWA=; 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=qysZ2ndgeahKh0fi+fczVOLo10/rNSZdFS1xcdZTMJUh49sDcovj6xBYsAyowdLbqHxLNnC4Tq uoCicVMxYi0fqZ6aSeyCBn2MDb7N6HjUMq0OlKOo9/RKlGmVSdMIfWYSGmKlRVCMdcZ/qYpAIq 5ka74EI5xbd4L8JkizCHy76E50u17H9D/yU8e+dqUar4vaLy6AiIxAjmkIc6b3TCcoNcT/Q8GH aKYd86yyFvW7QSDRWTwMCUwCypxYipswLa1Yrra5mMwhGkjNQPe6VRwH4g+66fzONTg5P0hiK1 rq1nGXc7ouWHvq+K5j4v1s04jZP2U+HqCZ4JZGWRFAWY1w==; 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=stHR/QojDR8+a8ymYf+k0iwwChw6ftImWsbyhR0pCM8=; b=ah6LXSx4GgD0eHsxz9IgUFmeVZ rSqsdkuEzSEDlZ225IiHzZLi3vHh6j8HAOwh64E7jgoZujifI0wERfdjO70F9Z42pkaVAigCs73JU sXyC+P9mvFQCCRMuBz2Ti4qbnp0rsRJGqR5PUhODTfdr+KfDYWbuQvefPaEwO0m+hI065/rmBfp+J gLimDwdvOC5nn5ne7tHRKNRj9RbM5O/JibNwK9TQSuGvoyEuGit/nP7T8kbRFoyhR1eZusk/A7TtL SehAwrw6i1WQwejVUxzB8vHW1wuZjdUj4n1kF9bfodViZfMxkm42OOUPOXaUHxkUpiFc7NovCIzqf TAUMzrMg==; Received: from authenticated user by zero.zsh.org with local id 1nkFfm-000ErG-Mp; Fri, 29 Apr 2022 01:43:54 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; 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-ej1-f46.google.com ([209.85.218.46]:42711) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nkFfE-000ENv-TT; Fri, 29 Apr 2022 01:43:21 +0000 Received: by mail-ej1-f46.google.com with SMTP id i27so12780538ejd.9 for ; Thu, 28 Apr 2022 18:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=stHR/QojDR8+a8ymYf+k0iwwChw6ftImWsbyhR0pCM8=; b=u76UXe44lJrGl71N4d8ew4AlCBM2W2e7nVrNjlrd82uqpKa22s24zYnmGklnyMmDFL biFZ9cjfKv49fi5tozo5HluT2Nw6kTJH2Jk47GDfiNJFtZ3yqY+MT0LYAFYEBwag0vmF nS7r/0mnx2PkjMKmfq9TNBBuffW0nnv2NSCG+8XuXG/QYvaS8d1Kio4xE0TVU8T/z09M xkDfwY0CkjSwVmpQPY1A76D/D330DCYE2mvOAPDjUyKRZNuLMvGh8ySwpAP/4CyfBfVS LHfDSmoqKSPjIJ58mIUWO2R4tYb0XmqwyFXIepNSzFNzp7rf92mndtlVABiLOdfu6tOH HCtg== 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=stHR/QojDR8+a8ymYf+k0iwwChw6ftImWsbyhR0pCM8=; b=SyXthQTKIsU88VV3Pzjp0Dt/YmrUzDciLQFARW1D0B9MZbRL44/HkYwY0RfYHiYCRB 3drGG8R8QU4H583pcm3oflpCD7o/ywlpGfVu3UosFlaFRblJ0ysdutVHo4ZSzBcfQraE ipVCSF5rcgjV2+AwuvnmBfG3nXVsWCG/UhqHElqZlXX3wIc6AYGe5j/O6+dIk8VouQj0 8tQvPz8C7gSzEU86/dZlCjZLAztfTTsHcwEyeCiTdusbYesPOzc3Uwp74qpDsL8ny0HU 2aU07M+nNY5imEvwMWWGWdGeSz0iXEooZBW5HmKYjQ/nw7R/6vE+eWkD/o5uKp6lbIKC Tbfw== X-Gm-Message-State: AOAM530ghbPjMvdJnTmV7Y7eN/7OLEL9uWeF8Mk6cqSbdZ7uTHQ++uL5 KNXeae0MhF/wEJDAUcLO/7H2DtYtdeepRaRgip8QT6n70CXjX/ae X-Google-Smtp-Source: ABdhPJzuN8PzxAeq+LB84zcQxZ729/QIvzXyDauT5EVhH5bANFbLgtO6bHNhqCKBDaTtR4J1kxmnMBWPrzizJHJaNkE= X-Received: by 2002:a17:906:c1d7:b0:6e8:4f18:fede with SMTP id bw23-20020a170906c1d700b006e84f18fedemr34164036ejb.95.1651196600359; Thu, 28 Apr 2022 18:43:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Thu, 28 Apr 2022 18:43:09 -0700 Message-ID: Subject: [PATCH] The thing about ":|: =(hang)" (Re: [PATCH] Fix users/26150 from Etc/BUGS) To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 50136 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: On Wed, Apr 27, 2022 at 10:24 PM Bart Schaefer wrote: > > The fix for > :|: =(nosuchcommand) > is probably going to be similar. As you might expect, this is a race condition. In getoutputfile() we have: os = jobtab[thisjob].stat; waitforpid(pid, 0); cmdoutval = 0; jobtab[thisjob].stat = os; In ":|: =(hang)", waitforpid() is looking for the PID of "=(hang)", but both the left side of the pipe and the command substitution exit during that wait. This means all jobs of the right-hand-side are done (because the right-hand side is in the current shell) so jobtab[thisjob] should be marked STAT_DONE, but that status is clobbered by restoring the saved state after waitforpid(). Saving and restoring the job state here dates from before we used git, but doesn't appear to be needed any longer -- all tests still pass with it removed. Any ideas how to prove this wrong? diff --git a/Src/exec.c b/Src/exec.c index c31089bb5..f2911807c 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -4883,13 +4883,9 @@ getoutputfile(char *cmd, char **eptr) child_unblock(); return nam; } else if (pid) { - int os; - close(fd); - os = jobtab[thisjob].stat; waitforpid(pid, 0); cmdoutval = 0; - jobtab[thisjob].stat = os; return nam; }