Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
job control in a script / zsh parallelism problem.
- X-seq: zsh-users 16891
- From: Simon Mages <mages.simon@xxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: job control in a script / zsh parallelism problem.
- Date: Thu, 15 Mar 2012 12:25:18 +0100
- 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==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author