Comming back on this 10month old thread... On Tue, Jun 30, 2020 at 12:30:53PM -0400, Chet Ramey wrote: > On 6/28/20 9:49 AM, felix wrote: > > > Bash Versions: 3.2.57(1)-release, 5.0.3(1)-release, 5.1.0(1)-alpha > > > > In order to reduce forks and make some tasks a lot quicker, I run > > forked filters as background tasks, with dedicated I/O fd. > > > > For sample, to convert human datetime to UNIX SECONDS, instead of running > > ... > > > > become a lot quicker!
Found this bash mandelbrot sample at Stackoverflow: https://stackoverflow.com/a/63749612/1765658 This script take many hours to draw a mandelbrot. Reducing number of fork to bc to only one, then same draw is done in less than 10 minutes. > But not guaranteed to work everywhere, especially those systems that use > /dev/fd and pipes for this instead of FIFOs. (And lack `stdbuf'.) Yes, to make this run under MacOS. I first dropped `stdbuf`, then because of an ``old'' version (3.2.57(1)-release) of bash, there is the most relevant part of my patch: -exec {bcout}<> <(:) -exec {bcin}> >(exec stdbuf -o0 bc -l >&$bcout) +fifo=/tmp/fifo-$RANDOM$RANDOM-$$ +mkfifo $fifo +exec 10> >(exec bc -l >$fifo) +exec 11<$fifo +rm $fifo You could have a look: https://f-hauri.ch/vrac/mandelbrot_backgndBc.sh.txt https://f-hauri.ch/vrac/mandelbrot_backgndBc_4macOs.sh.txt > > There is maybe something to document or even create a new feature > > about open2 and open3... I was wrong about ``open2'', there is already ``coproc''. But about ``open3'' permitting to pass all 3 STDIN STDOUT and STDERR, there is maybe something to do!? -- Félix Hauri - <fe...@f-hauri.ch> - http://www.f-hauri.ch