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.
|