From owner-freebsd-questions@FreeBSD.ORG Wed Nov 8 10:07:13 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E25EA16A412 for ; Wed, 8 Nov 2006 10:07:13 +0000 (UTC) (envelope-from nicky@valuecare.nl) Received: from smtp-vbr16.xs4all.nl (smtp-vbr16.xs4all.nl [194.109.24.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id D75CD43D98 for ; Wed, 8 Nov 2006 10:07:04 +0000 (GMT) (envelope-from nicky@valuecare.nl) Received: from [10.0.0.12] (a80-126-182-198.adsl.xs4all.nl [80.126.182.198]) (authenticated bits=0) by smtp-vbr16.xs4all.nl (8.13.8/8.13.8) with ESMTP id kA8A71wK074801 for ; Wed, 8 Nov 2006 11:07:04 +0100 (CET) (envelope-from nicky@valuecare.nl) Message-ID: <4551AC4A.2000108@valuecare.nl> Date: Wed, 08 Nov 2006 11:07:06 +0100 From: nicky User-Agent: Thunderbird 1.5.0.7 (X11/20061018) MIME-Version: 1.0 To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by XS4ALL Virus Scanner Subject: Parallel shell scripts. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2006 10:07:14 -0000 Hello, This might be a bit off topic, but can't find anything really useful when searching the internet. So i hope someone can point me in the right direction I have to start 2 processes in the background (running in parallel), capture their return codes and after all 4 have completed successfully i want to continue with the main script. Sofar i have this (below), however is this the proper way to do it? #!/bin/sh - PIDLIST="" ./childprocessA.sh & PIDLIST="$PIDLIST $!" ./childprocessB.sh & PIDLIST="$PIDLIST $!" for PID in $PIDLIST; do wait $PID rc=$? echo "Job $PID exited with status $rc" if [ $rc -ne 0 ]; then exit $rc fi done **** the rest of the main script **** Regards, Nick