1#include <stdio.h>
2#include <sys/types.h>
3#include <sys/stat.h>
4#include <fcntl.h>
5#include <unistd.h>
6#include <stdlib.h>
7#include <errno.h>
8#include <sys/wait.h>
9#include <string.h>
10
11int main(){
12	int pid;
13    int status;
14    pid =fork();
15    if(pid<0){
16        printf("Error");
17    }
18    else if(pid==0){
19         // Child Process
20         for(int i=0;i<100;i++){
21            value-=1;
22            printf("%d \n",value);
23         }
24        exit(EXIT_SUCCESS);
25    }
26	
27   waitpid(pid,&status,0); // WAIT till child gets over
28	// Parent process
29   for(int i=0;i<100;i++){
30            value-=1;
31            printf("%d \n",value);
32         }
33   printingFunction();
34    if (WIFSIGNALED(status)){
35        printf("Error\n");
36    }
37    else if (WEXITSTATUS(status)){
38        printf("Exited Normally\n");
39    }
40    return 0;
41    
42	}
43}1#include <sys/types.h>
2#include <sys/wait.h>
3
4pid_t wait(int *status);
5pid_t waitpid(pid_t pid, int *status, int options);1/** really not much to say...
2   just a way to program a delay
3   between commands in your code. **/
4
5//C library statement
6#include <time.h>
7
8//Driver program
9void dealy(int numOfSec)
10{
11	/* the delay itself runs with milli seconds
12	   so here we multiply the seconds by 1000.  */
13	int numOfMilliSec = 1000 * numOfSec;
14	
15	/* Making the time pass with nothing running
16	   until the time is up.                     */
17	time_t startTime = clock();
18	while(clock() < startTime + numOfMilliSec);
19}
20
21/*To use the delay just use the command:
22  delay(x);
23  you need to replace x with the number
24  of seconds that you want the delay to
25  be.                                    */
26  
27///The code itself without the details:
28
29#include <time.h>
30
31void delay(int numOfSec)
32{
33	int numOfMilliSec = 1000 * numOfSec;
34	time_t startTime = clock();
35	while(clock() < startTime + numOfMilliSec);
36}