creating 10 process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting creating 10 process
# 1  
Old 05-20-2007
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. Smilie Smilie Smilie

Last edited by kpkant123; 05-20-2007 at 03:05 AM..
# 2  
Old 05-20-2007
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.
# 3  
Old 05-21-2007
Quote:
Originally Posted by kpkant123
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. Smilie Smilie Smilie

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

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Process using/creating files in the filesystem

Hello Team, In a application filesystem, there is a process keep creating the log files. Due to that the filesystem keep getting full. Please let me know how to identify the process which is keep writing in the filesystem. fuser -u <FS> will show only the user who using the filesystem.... (3 Replies)
Discussion started by: gowthamakanthan
3 Replies

2. UNIX for Advanced & Expert Users

Unix script seems to be momentarily creating child process for unknown reason

Hi, I have a unix script that basically has a while loop inside which it checks Oracle database for certain records. If it finds the records, it does some processing and then goes back to the while loop. If it doesnot find any matching records, then it sleeps for 30 seconds and then goes back to... (17 Replies)
Discussion started by: waavman
17 Replies

3. Shell Programming and Scripting

Need help in creating a shell script to automate svnstats process

Hi, I am trying to create a shell script to automate the following process of getting svn stats:- Step1:- cd to checkout location. Note that the checked code have multiple modules in respective folders Step2:- Execute this command inside each module:- svn log -v --xml >... (0 Replies)
Discussion started by: d8011
0 Replies

4. Shell Programming and Scripting

creating an automation process in unix .

hi i need shell script in ksh for the automation process in informtica. The automation process is like this . i have a folder in unix . when this folder gets updated (like if a file or files is/are added to the folder) an event in informatica is triggered and after the process is done in... (2 Replies)
Discussion started by: kumar8887
2 Replies

5. Shell Programming and Scripting

Creating background process for my shell

I actually posted this problem on a different forum, but figured this would be a more appropriate place to post it. OK so I've created my own shell, but I can't get the background process function to run properly! What I want to do is to run a process in the background, and also print when the... (2 Replies)
Discussion started by: hansel13
2 Replies

6. Programming

Creating 3 process and piping a message

sorry im very new to this but i am supposed to create 3 processes A,B, and C and have a direct link from a to b, b to c, and c to a. here is my code. It does work, however if you look at what I bolded as long as my final read is p it seems to always work, regardless of the bolded section. ... (6 Replies)
Discussion started by: p00ndawg
6 Replies

7. UNIX for Dummies Questions & Answers

UNIX System Call for creating process

Hell Sir, This is chanikya Is there any System call which behaves just like fork but i dont want to return back two times to the calling func. In the following ex iam creating a child process in the called func but the ex prints two times IN MAIN. ex :- calling() { fork(); } ... (2 Replies)
Discussion started by: chanikya
2 Replies

8. Programming

creating child process

i want to create 3 child processes from the same parent using folk. I know how to use folk but my child processes did not come from the same parent. Any suggestion what i did wrong ? (12 Replies)
Discussion started by: Confuse
12 Replies

9. Programming

How to know a new file is in process of creating? It has not been closed.

I am programming some data loader of oracle with unix c, when I find new data file, then read it to database and delete it. but one issue, if the file is in process of creating, not been closed yet. I will read zero or part of data content, this will cause problem. I want to know whether some unix... (2 Replies)
Discussion started by: linkjack
2 Replies
Login or Register to Ask a Question