I'm trying to use a named pipe so I can keep stdout for status output from a long process. I could use stderr for status output, but I'd like to keep that for errors. Here is an example:
#!/bin/bash
pipe=$(mktemp -u)
mkfifo $pipe
dd if=/dev/zero of=$pipe bs=1M count=1024 status=progress & cat $pipe > test.bin
# ¿¿¿ Status of dd command ???
rm $pipe
The command isn't exactly what I'm trying to do, but illustrates the combination of using a named pipe for the output of one process feeding into the input of another. In my application, dd is replaced with some long running command, and cat with ssh. This would do what I want, but I don't know how to get the status of the dd command as $? would return the status of the cat command. If this were a pipe, I could use PIPESTATUS but that doesn't seem to work for parallel processes. In the actual application either (or both) commands could fail.
Is there a way to get the status of processes run in parallel? Is there a better way to accomplish this task using something other than named pipes?
ddcommand in the example.ddis just a stand-in example as I'm not actually using it in the actual application. I need to know if it fails.