This script
$ cat csub.sh
#!/bin/bash
while true;
do
sleep 5
AVAR=$(date; sleep 2)
done
when started, makes a process appear in the ps output:
ps -eLf|egrep '[c]sub.sh|PID'
UID PID PPID LWP C NLWP STIME TTY TIME CMD
jimmy 31364 23445 31364 0 1 00:33 pts/7 00:00:00 /bin/bash ./csub.sh
which is quite predictable
as well as the fact that $(date; sleep 2)
spawns another process
Surprising is that the spawned process has identical CMD displayed
UID PID PPID LWP C NLWP STIME TTY TIME CMD
jimmy 31364 23445 31364 0 1 00:33 pts/7 00:00:00 /bin/bash ./csub.sh
jimmy 31433 31364 31433 0 1 00:33 pts/7 00:00:00 /bin/bash ./csub.sh
I added sleep to be able to catch the process into the ps output, otherwise one have much less chances to, because it's too short. As you see the spawned process 31433 has 31364 as its parent. I would expect the spawned process has some different CMD mentioning what it deals with, e.g date or sleep command. For cases when there are multiple command substitutions, how could I distinguish them when I see a spawned process appeared?