zsh-users
 help / color / mirror / code / Atom feed
From: nix@myproxylists.com
To: zsh-users@zsh.org
Subject: Is this possible in ZSH?
Date: Sun, 14 Nov 2010 15:12:25 +0200	[thread overview]
Message-ID: <f15da59a0d6892172fc4c8f15cee0c59.squirrel@gameframe.net> (raw)

Hi.
#!/bin/zsh

[CODE]

zmodload zsh/terminfo
emulate zsh

function Echo () {

# This function simulates background process that executes in a random period

#local A
#local B

A=$1
B=$2

sleep $B

echo "Key: $A Value: $B"
}

A=0
RANGE=15

while [ $A -lt 4 ] ; do

Rnd=$RANDOM
let "Rnd %= $RANGE"

# - Fork

Echo $A $Rnd & # <-----------
let "A++"

done

wait

[/CODE]

Is it possible to append background process results to a variable or to an
array without waiting for that job to finish? So as soon as "Echo"
function finishes, it´s results would be appended instead of file to
variable. I have tried it but every time it waited for the process until
it finished and i lost my multi-threading.





             reply	other threads:[~2010-11-14 13:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-14 13:12 nix [this message]
2010-11-14 20:10 ` Bart Schaefer
2010-11-14 22:01   ` nix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f15da59a0d6892172fc4c8f15cee0c59.squirrel@gameframe.net \
    --to=nix@myproxylists.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).