From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id a43ea050 for ; Wed, 18 Dec 2019 04:38:57 +0000 (UTC) Received: (qmail 4539 invoked by alias); 18 Dec 2019 04:38:50 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24572 Received: (qmail 9265 invoked by uid 1010); 18 Dec 2019 04:38:50 -0000 X-Qmail-Scanner-Diagnostics: from mail-yb1-f170.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25663. spamassassin: 3.4.2. Clear:RC:0(209.85.219.170):SA:0(-1.9/5.0):. Processed in 1.928852 secs); 18 Dec 2019 04:38:50 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.219.170 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=c77SMaQkwltlUUSH1g67/GK5cWt966JD3vANF0c/rOM=; b=JekKTm1IU/jrNLR4Ap97jLSVXIR7oFrZJ/hgK5E5BI5sTKsLz+GBsrq/CBOWAB31jz 51Zmr70to24nCRzh9037NKw5iwObp4ejzbleaKfCUWkYLxab9ztbvyPAWzHbuKMkFafC 2S71KinpiKIVHWvYF7fVc+KTB7lLwmnIhc/NhItZAt7Prza7fOOp2DtVOTryfUUPakax Md/87q2wP5FIXWiBsSbpgWoUG9Z7V9t1vDA8JHYIaWt0Z1IUU02GHcvnSxUTEA4aub7m 0a9sih2BRT/FKu0VY0HPcgRrEE6FIeYDXf1dIpY0DB8+NzkD2tOua/NQ0NaGKhSOroeZ g70A== X-Gm-Message-State: APjAAAVgtaJnK/uOce9YLY9Ebnf22EynU2QVqBcYvyY+PxdjdUzZ1XeL HH9CPBQd2FCM5a5J7PPAdMdi9Q== X-Google-Smtp-Source: APXvYqzaWIfAcAO9Jv4UTK4DMhccRBOaQDaFVAr2CtUDu/BSlQAV8fqoHIUYYU8dNEYNEb55asmCUg== X-Received: by 2002:a25:701:: with SMTP id 1mr363164ybh.81.1576643894824; Tue, 17 Dec 2019 20:38:14 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: is '&' the right way to do this? From: dana In-Reply-To: Date: Tue, 17 Dec 2019 22:38:13 -0600 Cc: Zsh MailingList Content-Transfer-Encoding: 7bit Message-Id: References: To: TJ Luoma X-Mailer: Apple Mail (2.3445.104.11) On 17 Dec 2019, at 06:33, TJ Luoma wrote: > ( find / -type f -print > /tmp/filelist.txt ) & Technically you don't need the parentheses in this example On 17 Dec 2019, at 06:33, TJ Luoma wrote: > Question #1: Would it be better for any reason to use `&|` such as: > or is the use of `&|` really only beneficial for interactive shells? When the MONITOR and HUP options are both enabled, the shell will automatically send SIGHUP to all jobs in the job-control table when it shuts down (which usually kills their processes). Disowning a background job with &|, &!, or disown removes it from the job-control table, which prevents it from receiving the signal Since MONITOR is only enabled by default in interactive shells, the main benefit of disowning doesn't usually apply in scripts. However, it doesn't hurt anything either, and it may be useful in rare cases, e.g., where you specifically want to exclude certain jobs from the job-control table On 17 Dec 2019, at 06:33, TJ Luoma wrote: > Question #2: Are there better ways of doing this? There are other options that you might use in some scenarios, like coproc and nohup and setsid and even systemd, but & is probably fine for the general use case of 'run a job asynchronously / in the background'. I think so, anyway dana