creating 10 process

can anyone tell me how to Create ten processes and display useful information about them including PID, starting-time in unix using c or c++ language. i tried to create 10 different processes using fork and exec but i couldn't display those process info:PID,STIME.

my sample code

......
......
pid = fork();
if(pid == 0)
{
execl("/bin/ls", "ls");
}
elseif(pid == -1)
{
/error handling
}
else
{
execl("/bin/ps", ""ps);
}
.......
........
parent process execute 'ps' command
child process execute 'ls' command
the script should display pid and stime of those processes:'ps' and 'ls'. like this i want to create 10 processes and display info.please give me ur suggestions to develope a code myself. :confused: :confused: :confused:

You don't directly use fork in a shell script and exec has a different meaning in the shell. Since you posted in "Shell Programming and Scripting Q & A", I assume you are talking about a Posix compliant shell. If this is not the case, you should specify the language.

pid=
for p in 1 2 3 4 5 6 7 8 9 10
do
  ls &
  pid="$pid $!"
done
ps $pid