From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26715 invoked by alias); 15 Mar 2012 11:50:34 -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: X-Seq: 16891 Received: (qmail 24799 invoked from network); 15 Mar 2012 11:50:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.215.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Y/qG61aNt+ujKZkUoteShblp7VFG9ruJbxNRS+bN3jk=; b=sTzlUvj/eduxZciUaeCOVRcBbfG/KVBcSt6x8mBca822jRm6GYQVzC0V/cvbCoWmCD SlPQhSb4DscADN/er85h/r9XCpnS2fO2zVAypMwxDdfdRaNqVmRPsmVSIHrjYufV+Zp+ goazdwc5E69NxtLriR6snLxesaDUGIfSATQ7a862Y+YFT08A0aVymyIJJarKSJYXy5KV mQTGcLoXtRAJwcIj06qZmYgcxhiyOaE5fGEag3dODVA5xZ5VLzmdtok9ptqMRTjBSl1U 0KHarWb0FETf/V6zwEjov1pDX2bscIWFgtMiZGD4Z+/q73oGaSw6ocab5H5I43cwLANb Wbtg== MIME-Version: 1.0 Date: Thu, 15 Mar 2012 12:25:18 +0100 Message-ID: Subject: job control in a script / zsh parallelism problem. From: Simon Mages To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=0015174bdcf6cbb20004bb465815 --0015174bdcf6cbb20004bb465815 Content-Type: text/plain; charset=ISO-8859-1 Hi, i have some Problems with the job control in zsh. In the following Script i tried to start 3 background processes, because thats the only way i know to run things parallel in zsh, and write a "dot" every two seconds during the runtime of this background Processes. #!/usr/bin/zsh #set -x for i in a b c do sleep 120 & done jobs -l jobs -l |wc -l var=`jobs -l|wc -l` while [ $var -gt "0" ] do print "." sleep 2 var=`jobs -l|wc -l` done The Problem is that "jobs -l" in the Script writes an complete background process list to stdout but "jobs -l|wc -l" just prints a "0"? When i run "jobs -l|wc -l" manual with some background jobs it is working fine. Can someone Point me i the right direction, i'm running out of useful ideas. Here the Output of the Script without set -x: #> ./test.sh [2] 4916 running sleep 120 [3] - 1716 running sleep 120 [4] + 4160 running sleep 120 0 here with set -x: #> ./test.sh +./test.sh:5> i=a +./test.sh:5> i=b +./test.sh:7> sleep 120 +./test.sh:7> sleep 120 +./test.sh:5> i=c +./test.sh:10> jobs -l [2] 3532 running sleep 120 [3] - 1600 running sleep 120 [4] + 5292 running sleep 120 +./test.sh:7> sleep 120 +./test.sh:12> jobs -l +./test.sh:12> wc -l 0 +./test.sh:14> var=+./test.sh:14> var=+./test.sh:14> jobs -l +./test.sh:14> wc -l +./test.sh:14> var=0 +./test.sh:16> [ 0 -gt 0 ']' My test environment: #> zsh --version zsh 4.3.12 (i686-pc-cygwin) BR Simon --0015174bdcf6cbb20004bb465815--