Reputation: 4633
It seems some answers on the site but those seem not to resolve my question.
Say,
#/bin/sh
fpfunction(){
n=1
while (($n<20))
do
echo "Hello World-- $n times"
sleep 2
echo "Hello World2-- $n times"
n=$(( n+1 ))
done
}
fork(){
count=0
while (($count<=10))
do
fpfunction &
count=$(( count+1 ))
done
}
fork
I am expecting to "fork" this parent process to the number of 10 child processes.
The way I check that those child processes are actually created is to type "ps -l" command.
I am a newbie to the shell world and please let me know how to archive this.
Thanks in advance.
Upvotes: 6
Views: 35804
Reputation: 798696
The ampersand (&
) after a command will run it in a forked subshell.
fpfunction &
Upvotes: 11