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=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10067 invoked from network); 27 May 2022 16:11:03 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 May 2022 16:11:03 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1653667863; b=rNPGmFWDB8w0JZYjQ/hnGepc+S4nmPvGFb6sWYfLBiHJB/acoDhHUpeIdddkgNDV5eoopp09f+ wuapS9R1fX0pd2wrapoFwvknwV3Gu4U+go9P7K0YxbxenkUAVq3QbaIGtuKHNE06Hyy2no34uR lJ4as8yH9Acy5fzBBhG69EBEq+wlu9JUASBAXYQyJcaa+hyUrnPlCOLloWTU+EKp1cVieg8Spg PRIV93ozGnQ7497mHncRJga0xwJnmXiuOhh9BrllCJowW+HIxRnSyN2hBbG7arkbOQFpNjns/L d66fxAVYc0aIcNE8nni8HKD34fWGeJhYHMgKX8Ec7LH9BQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f41.google.com) smtp.remote-ip=209.85.208.41; 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=1653667863; bh=HHwBMZFQkUAJwVBMCGpR+Dp6wcsp38hKio8q58PA/2I=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=XpE8Ceifc1fVXLG+fpjqDNBqIaXxxzXakCg65ogxqVjgV7Wf4yf+XyJVy9fEzav9U8okaiyCgU AIX1mPOSCspz+GOsg9DNeby6hvDYe/2cRRr7/hg1eQ89oUBam9/J4ZcM3QNqMW+6xNW6zJ3vNz qkYAFeVCy/t2/jCtMFumaRSNjOWLzBQtSF564891Ryldfxt0gjDlccisrz7YtuZ6IRjnSAjW+l 95hiroooo9GhJBIby+EqKBwelQ5uw5lkCAx2W5ZKw1vnqtnYcrpQ+DY6QOzoIhOvZWbmO8NNqz DjIOb+aIEsW/Oyki0LJcFZmJTYcVV+hWDWyvDa99e/x6ag==; 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:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Na0rdR5tehxA1oijORJUM4sBRe+mlUAwDoqu5YTx6WY=; b=lGdZDO9KflO2wbBPpPDrb2TVwZ qfAh0iTnWD8rtPEq/2uwQYTxwPrqKKFzxTCbbmsAKE0ceMVArcnhTyUAaL392KIpDY14BYTWajwjI AEA67I2aDPlrcX78d+1UTxVQ77qn5kVx2saQc7djB6Fdc6fseF51i4rhCTwwnwXUmQ4K0Dvuwgo7B 4ilsLkIUhsnuP/eE8BIplYpEUYpvJyotZ3PqJiZafPh0o7NCSKKi+NF/Wwmjp5MKaeTE4875+dmS3 b8PQMBiJxF3+xDgsz8yZ8PLz5HDb30hK3VRF8KfzQjOiVOOSVuQWq61pPMuWvbJLlFBRB1yZkKY7j IP8lyFVQ==; Received: from authenticated user by zero.zsh.org with local id 1nucYH-0006b8-Ix; Fri, 27 May 2022 16:11:01 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f41.google.com) smtp.remote-ip=209.85.208.41; 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-ed1-f41.google.com ([209.85.208.41]:34409) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nucXx-0006Gi-Ma; Fri, 27 May 2022 16:10:42 +0000 Received: by mail-ed1-f41.google.com with SMTP id z43so1523111ede.1 for ; Fri, 27 May 2022 09:10:41 -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 :cc; bh=Na0rdR5tehxA1oijORJUM4sBRe+mlUAwDoqu5YTx6WY=; b=HQ5VRrb+DryYnCLmpfrQaPS9Z0NC8LnYz0ZjwU+NsKs4ismI4JnGtZ3qwUswcjzx7/ V0xADMnoFK6ayt4eHPokLerYcW7x0rR+fjBQT9IT1ami4qBqlSBhlPE4WToyle4BvF1u 9VTG/8L8n9/8sv8zSO8i8WJuw0OCRIX4k/KeKS/Vo0dh9FMpndV0BvE4c1EXOuE3PzF1 Zbamm16XehBMnTJR+UHtDatanrZo4LSVT/zf+4QvIEe77Or53DWUYt0je0MuPXnipJx9 DZqjGauw83mD9dCirUcvyZ5Ny8d1oKEd9N5LihVngdqtsfOGYJWWdAdv+DiLfpMdccgp xoqg== 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:cc; bh=Na0rdR5tehxA1oijORJUM4sBRe+mlUAwDoqu5YTx6WY=; b=srz+XHftutxuMGYR7sLzMR9aVZZf7cvN43mTn5oTSsVBX4mGM2imYshVw+Sy2Zi3Ht 7whL+7AUrK4FfgfxaFl9WPmZaNMgG7mblIRDic2ZLz4zf3IPpQRb6S+A6pw2/5mULDu7 R8nNg1XmKpwZ/ucWr+RhzQTVscRNin0wo5BGFmVpmqIHJoFdaiyA0BUvpDkZhmbufdDW MDd2rog5/jqVJLqNVy3DJqgIfgV7uD2AKBx6jnvSTBunyaondEUbsqbgJuL5d/7rV96T 2gCcH3PkqzM6PJq8NBnwXoXc7naHDmQYPwD+EJ232pJ/9sm7BScFB7tINS10WFgdRvMs ZSsQ== X-Gm-Message-State: AOAM532J1nx5Gy+3X/GQsJJANVtpfWQ7+H9eyIOVzdzvR3JwCcMjNrce ZoVDdnAPE5EJ8HVVh2scA6y+TsiaNdcjbrIBKE1oMKfAaYY= X-Google-Smtp-Source: ABdhPJyL0jFOH3/tuXSL6UBLk73wro32CDE2YMuy9ejFPQzd1+zuTDF+z+LHqmisb5c1UFKfngRl04f993h2uDeI4Sg= X-Received: by 2002:a05:6402:1151:b0:42a:be24:5529 with SMTP id g17-20020a056402115100b0042abe245529mr45564285edw.366.1653667841173; Fri, 27 May 2022 09:10:41 -0700 (PDT) MIME-Version: 1.0 References: <9162a41e493cabeb0c8fb7c770f6b35035a0be0e@hey.com> <8CB92976-5B21-4239-844E-93C88EC734F5@kba.biglobe.ne.jp> In-Reply-To: <8CB92976-5B21-4239-844E-93C88EC734F5@kba.biglobe.ne.jp> From: Bart Schaefer Date: Fri, 27 May 2022 09:10:29 -0700 Message-ID: Subject: Re: zargs with -P intermittently failing in zsh 5.9 and macOS To: Jun T Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 50296 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 Thu, May 26, 2022 at 10:30 PM Jun T wrote: > > When wait_for_processes() is called (in signal handler?), wait3(&state) > _sometimes_ returns with WIFCONTINUED(status) set to true. > Then wait_for_processes() calls addbgstatus(pid, val) with > val=WEXITSTATUS(status)=19. > > Later the process exits normally, and addbgstatus(pid, 0) is called. > This means bgstatus_list has two entries for the pid. > > When 'wait pid' calls getbgstatus(pid), it finds the entry with status=19 > and returns it. Even if it's correct to have two entries, it's wrong to return the least recent one. > A simple fix would be, at line 584 of signals.c, > (A) call addbgstatus() only if WIFCONTINUED() is not true. I think that's insufficient ... we should be recording the most recent state, per your question about WIFSTOPPED. > So I guess we need to call addbgstatus() only if the process has actually > exited (or killed). If this is the case, better solution would be > (B) call addbgstatus() only if WIFEXITED() or WIFSIGNALED() is true. > This it the patch below. Does that really work? I would expect WIFSIGNALED to be true when each of WIFSTOPPED and WIFCONTINUED is also true, so it wouldn't change anything? (There isn't any way to stop/continue without using a signal that I can think of.) > Or, if we want to call addbgstatus() unconditionally, > (C) modify addbgstatus() so that if there is already an entry for > the pid then update it instead of adding a new entry. I think either that, or (D) Make sure getbgstatus() always returns the most recent entry. But ... there isn't any way for a user / script to examine more than one job status per PID, so unless we're using it internally somewhere (?) I would think (C) is best.