Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) 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.1
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;
        bh=HNybGYID3qQJB++k/m6Em5T2GweW7GPOiHOwojktpb4=;
        b=u/+daFe5CfEkAIcqpt67tbLSTp5DTdrVSPi3nx6AOWTREwBxJXUE3n1WLJ3GlR0G18
         M3zRk2Z7lHn3FdWu1xpxdGThY/sm0k8rv6pqPi+I8sajF+HkpdmzZe0W6OCyRJMV87Y4
         VjTyPhCZMYMXkE+0lPOfrQJx3ObpAwBer16ibkZebeS0shtsgycwEdQwj4Lc5boQhNza
         IR3Wp7og7cLkRdEMdsQs0/P3GQvJxkEWJzFFj3zUxR9TVKkaCN9QiCLpuFFrDJWnUqZ0
         MB3IGq8ZqGXE8FT82Vg4E1FZoxvsxI0hgELiM6bO5o3lKW9Njp0IQcmX9ay/EprlvtCv
         8ibw==
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;
        bh=HNybGYID3qQJB++k/m6Em5T2GweW7GPOiHOwojktpb4=;
        b=AsyfgZ85zMYOtvEfJuBJLGNT4M0dGgHfOqsgVS2MewXSryJE96ta5pFzcs1sMb60mD
         aTyF49XSt8tcGvWrCB5N6V5LFNzJcXOuphlcS0mu6sA1Pv+F5GaxXSk4GCmawoXMjhyz
         WPrn+Mft4srUo0stVJpGiI8bmX+1znZ8uKHmIy2670Vnm+fEvJf5oEDWG1+2xnHavgXq
         mE3kx7sLzBRrd2Ahg+oMcOHk4EZZM8aZ5I0841fxo8Km53a3xG/AdjLIww3OJVHLlg0S
         LnODDgVGMYD6HfaMsSZC7jahYJsHmtsnRSSeqvd5Gpf0dOQldfRnqWPfVfgQ6uFpwQqd
         tD4Q==
X-Gm-Message-State: AOPr4FUCb7ypK99W85VZwRbIiFOFC5xNPHFuptenZmzvpTq3RCtptf/tdvJ62yeo18ITyg==
X-Received: by 10.66.90.163 with SMTP id bx3mr37915871pab.59.1460824468322;
        Sat, 16 Apr 2016 09:34:28 -0700 (PDT)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160416093433.ZM24261@torch.brasslantern.com>
Date: Sat, 16 Apr 2016 09:34:33 -0700
In-Reply-To: <20160416075941.GA27994@ofb.net>
Comments: In reply to frederik@ofb.net
        "exec redirect prevents trap" (Apr 16, 12:59am)
References: <20160416075941.GA27994@ofb.net>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: frederik@ofb.net, zsh-workers@zsh.org
Subject: Re: exec redirect prevents trap
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 38292

On Apr 16, 12:59am, frederik@ofb.net wrote:
}
}     #!/bin/zsh
}     exec > >(tee -a /tmp/foo)
}     trap "echo hi" INT TERM EXIT
}     sleep 1d;
} 
} When I run it and hit ^C, it doesn't print anything. But when I remove
} the "exec" line and do the same, it prints "hi".

I suspect what you have here is a race condition.  When zsh exits,
it first sends a HUP signal to all its children, including the tee
process.  If tee dies before the exit trap runs, the "hi" will go
nowhere.

Try one of these:

    exec > >(trap '' HUP; tee -a /tmp/foo)

    exec > >(tee -a /tmp/foo &! )

