bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New Feature Request


From: Greg Wooledge
Subject: Re: New Feature Request
Date: Mon, 4 Jan 2021 08:14:54 -0500
User-agent: Mutt/1.10.1 (2018-07-13)

On Fri, Jan 01, 2021 at 10:02:26PM +0100, Ángel wrote:
> Yes. In fact, you can already do that using an interface exactly
> identical to file operations:
> 
> # Store a string in shared memory with key 'foo'
> echo "Hello world" > foo
> 
> # Read value of key foo
> var="$(<foo)"
> 
> 
> You only need to use that on a tmpfs filesystem, and it will be stored
> in memory. Or, if you wanted to persist your shared memory between
> reboots, or between machines, you could place them instead on a local
> or networked filesystem.

It should be noted that $(<foo) still forks a process.  If you want the
script to be faster, you'll need some other way to read the data from
the file -- perhaps using the read -r -d '' command, or the mapfile
command.

Other forms of IPC that are viable in scripts include using a FIFO that's
held open by both parent and child, or launching the child as a coprocess.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]