Operating System - HP-UX
1753444 Members
4976 Online
108794 Solutions
New Discussion юеВ

Re: language and scripting

 
Soumya Poddar
Advisor

language and scripting

sorry i have another question

this time for the multiprocessing

in c we write

int main()
{
int pid=fork();
if(pid<0)
{
printf("error");
exit(-1);
}
else if(pid==0)
{
.....
}
else
{
wait(NULL);/* wait for child to complete*/
exit(0);
}

here how karnel can understand that the parent
process waiting for it's child to complete
plese reply
6 REPLIES 6
Laurent Menase
Honored Contributor

Re: language and scripting

fork() returns 0 in the child process
and returns the pid of the child in the parent process.
So if pid!=0 it means that we are executed in the parent process.
then wait() check if child process are zombies, else wait for the next child process dying. When a child process die it wakes up the parent process.
Soumya Poddar
Advisor

Re: language and scripting

can you please tell me
how I can adopt with HPUX very quickly

learn the basic unix commands and the shell programing

it will help me a lot
Dennis Handly
Acclaimed Contributor

Re: question on fork

(It would be more helpful if you used a subject that included your question and not the name of the forum.)

>how I can adopt with HP-UX very quickly
>learn the basic Unix commands and the shell programming

If you know the command, fork, you can use man to look it up. Unfortunately there isn't an example there.
You could just search the web for: C fork examples

Soumya Poddar
Advisor

Re: language and scripting

thank you sir
Dennis Handly
Acclaimed Contributor

Re: question on fork

>thank you sir

If you are happy with the answers you were given, please read the following on how to assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33

Your unassigned points:
http://forums.itrc.hp.com/service/forums/pageList.do?userId=WW459660&listType=unassigned

James R. Ferguson
Acclaimed Contributor

Re: language and scripting

Hi:

> learn the basic unix commands and the shell programing

A good quick look at using various shells can be found here:

http://docs.hp.com/en/B2355-90046/index.html

Regards!

...JRF...