From: nix@myproxylists.com
To: "Bart Schaefer" <schaefer@brasslantern.com>
Cc: zsh-users@zsh.org
Subject: Re: Is this possible in ZSH?
Date: Mon, 15 Nov 2010 00:01:05 +0200 [thread overview]
Message-ID: <ccaba469d2aefbace4b084e62986d1ed.squirrel@gameframe.net> (raw)
In-Reply-To: <101114121011.ZM28022@torch.brasslantern.com>
> On Nov 14, 3:12pm, nix@myproxylists.com wrote:
> }
> } Is it possible to append background process results to a variable or
> } to an array without waiting for that job to finish?
>
> You're effectively asking whether the shell implements multiprocess
> shared memory, because otherwise "process results" are only available
> as either pipe I/O or as the exit status of the job. The short answer
> is no, you can't declare a shell variable that shares writable memory
> with a forked child.
>
> There are several alternatives to simulate the effect you want. You
> can use either coprocesses (several examples are in the mailing list
> archives, search for "coproc") or the zsh/net/socket module to set up
> multiple simultaneous connections from background jobs to the shell.
> You can use a trap on SIGCHLD or a loop on zselect (the zsh/zselect
> module) to pick up the data as the jobs exit.
>
> Or you can use the zsh/mapfile module to simulate a shared variable.
> Compare:
>
> x=32
> repeat 3 do (let "x /= 2"); print $x; done
> unset x
>
> zmodload zsh/mapfile
> mapfile[shared]=32
> repeat 3 do (let "mapfile[shared] /= 2"); print $mapfile[shared]; done
> unset 'mapfile[shared]'
>
> Just be sure the name you use in place of "shared" is something unique,
> because you will destroy the contents of any file in $PWD that has that
> name.
>
Thanks for this hint, i try to reproduce something based on your help.
prev parent reply other threads:[~2010-11-14 22:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-14 13:12 nix
2010-11-14 20:10 ` Bart Schaefer
2010-11-14 22:01 ` nix [this message]
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=ccaba469d2aefbace4b084e62986d1ed.squirrel@gameframe.net \
--to=nix@myproxylists.com \
--cc=schaefer@brasslantern.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).