I am using pipexec tool to manage communication between processes. My task requires me to retrieve ids of processes that communicate.
Example:
pipexec -- [ A ./cmd1 ] [ B ./cmd2 ] "{A:1>B:0}" "{B:1>A:0}" &
Then:
ps --ppid xxxx
Where xxxx is pid of pipexec process. Can I be sure that there will be exactly 2 processes displayed or is there possibility that pipexec run some internal process at some point of running?
From the pipexec
man page:
pipexec creates an arbitrary network (directed graph) of processes and pipes in between - even cycles are possible. It overcomes the shortcomings of shells that are typically only able to create non cyclic trees.
pipexec also monitors all it's child processes and is able to restart the whole network of processes and pipes if one crashes. Therefore pipexec can be used in SYSV-init or systemd configuration to run a network of processes.
So, it's possible that in case of failures when pipexec
restarts the the "network", it could create more processes than you could know.
But assuming there are no failures, it appears that pipexec
creates just the number of processes you have specified. Experimentally, I see:
$ ps -af
UID PID PPID C STIME TTY TIME CMD
usr 6531 29605 0 13:02 pts/9 00:00:00 pipexec -- [ A /bin/sleep 30 ] [ B /bin/sleep 40 ]
usr 6532 6531 0 13:02 pts/9 00:00:00 /bin/sleep 30
usr 6533 6531 0 13:02 pts/9 00:00:00 /bin/sleep 40
when running:
pipexec -- [ A /bin/sleep 30 ] [ B /bin/sleep 40 ]
This may or may not be universally true. But I couldn't find anything in the documentation that says anything on this.