From owner-freebsd-questions@FreeBSD.ORG Thu Nov 1 16:38:19 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B8DC116A419 for ; Thu, 1 Nov 2007 16:38:19 +0000 (UTC) (envelope-from naylor.b.david@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.182]) by mx1.freebsd.org (Postfix) with ESMTP id 61CAD13C4A5 for ; Thu, 1 Nov 2007 16:38:19 +0000 (UTC) (envelope-from naylor.b.david@gmail.com) Received: by py-out-1112.google.com with SMTP id u77so1064127pyb for ; Thu, 01 Nov 2007 09:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; bh=tSU1wgx8Go2JL9gCH4Ql0utib/6GC8vhFQ4/gOFbk+A=; b=b6nQmA22iu0TxNdGL23jbIh/DenkjEBtFZp1FBY5NcFTFPkqB7tGmcAmfZKMmXhmWa1+GvSXfvD9wyfI4FBWVxXb72jS75iEXgUEHKnUmNyel4YtvAZOQnNwyRE+M0IepyTYCZKLNK7e86ETsTLsjvCMiiPTpnShRD+gIhiHZ0s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=nMvBpi6NQVHLUCCV/uGp6hAcmLPSgrR/QBJ32YJpz/2k1R+CapoSMEVosuwkDjL1cTqaXq0M1PqYxrJDPFI+RUjpEB1PSYAw932pOSO+7Wtdgp6vWmOivTirryCa/r4f89SkU3JtV09J9vgJWuDjgELbJYhuMJQpRVzltQCAL8k= Received: by 10.64.142.10 with SMTP id p10mr4228787qbd.1193934680783; Thu, 01 Nov 2007 09:31:20 -0700 (PDT) Received: by 10.65.231.2 with HTTP; Thu, 1 Nov 2007 09:31:20 -0700 (PDT) Message-ID: Date: Thu, 1 Nov 2007 18:31:20 +0200 From: "David Naylor" Sender: naylor.b.david@gmail.com To: freebsd-questions@freebsd.org MIME-Version: 1.0 X-Google-Sender-Auth: a2ffaa617be3d889 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: sh script difficulties (running parallel functions) 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: Thu, 01 Nov 2007 16:38:19 -0000 Hi, I am having a hard time getting (very complex script for me) to work. The basic idea is that this script runs a bunch of tarkets, many of which are time consuming but low on resources (such as downloading files). Now if I run the tarkets all at once (given some dependancy issues) it greatly speeds up the process (about 5 time speed increase). However I do not know how to do this using sh... Example #!/bin/sh worker1() { # Copy some files } worker2() { # Download some files } worker3() { # Do something else } ..... # and so on run_jobs() { worker1 & worker2 & worker3 & # !!! Somehow wait for over workers to finish before continuing !!! } #Finished Furthermore, how can signals be handled such that the signals get accumulated and once all the other workers have finished the signals get passed on (appropriately) Thank you. David