Feel free to give me some guidance!!?!
Edited by rescueme, 06 February 2009 - 11:46 AM.
Edited by rescueme, 06 February 2009 - 11:46 AM.
|
|
|
Edited by rescueme, 06 February 2009 - 11:47 AM.
#include <unistd.h>
#include <stdio.h>
int main()
{
pid_t pid;
switch( (pid=fork() ) )
{
case -1: /* fork failed */
fprinf(stderr, "fork() failed!\n");
exit (-1);
case 0: /* child process */
printf("In the child process\n");
printf("Code in this block will not be"
"executed in the parent process!"
);
break;
default: /* parent process */
wait(); /* guess what it does? */
printf("In the parent process\n");
printf("Code IN THIS bLock wiLL not be"
"executed In the cHiLD process!"
);
break;
}
printf("Code here will be executed by both parent"
"and child processes\n"
"If you see these messages twice, than it's"
" correct!\n"
);
}
Edited by Lance, 05 February 2009 - 07:15 PM.
with -> will
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
pid_t pid;
switch( (pid=fork() ) )
{
case -1: /* fork failed */
fprintf(stderr, "fork() failed!\n");
exit (-1);
case 0: /* child process */
printf("In the child process\n");
printf("Code in this block will not be"
"executed in the parent process!"
);
break;
default: /* parent process */
wait(); /* guess what it does? */
printf("In the parent process\n");
printf("Code IN THIS bLock wiLL not be"
"executed In the cHiLD process!"
);
break;
}
printf("Code here will be executed by both parent"
"and child processes\n"
"If you see these messages twice, than it's"
" correct!\n"
);
}
Edited by rescueme, 06 February 2009 - 11:45 AM.
Edited by Lance, 05 February 2009 - 07:52 PM.
and -> create