#include<stdio.h>#include<stdlib.h>#include<unistd.h>intmain(){int x =0;int rc =fork();if(rc <0){
fprintf (stderr,"creat child failed \n");exit(1);}elseif(rc ==0){
printf ("the value of x in child is {x:%d}\n",x);
x =50;
printf (" value of x changed is {x:%d}\n",x);}else{printf("the value of x in father is {x:%d}\n",x);
x=100;
printf ("the value of x chnaged is {x:%d}\n",x);}return0;}
#include<stdlib.h>#include<sys/types.h>#include<sys/wait.h>#include<unistd.h>#include<stdio.h>intmain(int argc,char*argv[]){
printf ("hello world (pid:%d)\n",(int) getpid ());int rc =fork();if(rc <0){fprintf(stderr,"fork failed \n");exit(1);}elseif(rc ==0){int wc =wait(NULL);
printf ("hello, i am child of %d (wc:%d) (pid :%d)\n",rc,wc,(int)getpid());}else{printf("hello , i am parant (pid%d)\n",(int)getpid());}return0;}
```cpp
#include<iostream>#include<cstdlib>#include<unistd.h>usingnamespace std;intmain(){int x =0;int rc =fork();if(rc <0){printf("creat child failed.\n");}elseif(rc ==0){printf(" this is child.\n");execl("/bin/ls","ls","-l",NULL);
execle ("/bin/ls","ls","-l",NULL,NULL);execlp("bin/ls","ls","-l",NULL);}else{printf(" father .\n");char*a[]={"ls","-l"};execve("/bin/ls",a,NULL);execv("/bin/ls",a);execvp("/bin/ls",a);}exit(1);return0;}
#include <stdio.h>#include <stdlib.h>#include <unistd.h>int main(){ int x =0 ; int rc = fork(); if (rc <0) { fprintf (stderr,"creat child failed \n"); exit(1); }else if (rc == 0) { printf ("the value of x in child is {x