Horje
two way communication between child and parent processes in C using pipes Code Example
two way communication between child and parent processes in C using pipes
#include <stdio.h>
#include<stdlib.h>
#include 
#include<unistd.h>
int main()
{
    pid_t pid;
    int r;
    char *ch=NULL;
    char *ch1=NULL;
    int readpipe[2];
    int writepipe[2];
    int a;
    int b;
    a=pipe(readpipe);
    b=pipe(writepipe);
      // check a and b

    pid=fork();
    // check pid

    if(pid==0)
    { //CHILD PROCESS
            close(readpipe[1]);
            close(writepipe[1]);
            read(readpipe[0],ch,sizeof(ch));
            printf("\nREAD = %s",ch);
            close(readpipe[0]);
            ch1="YES";
            write(writepipe[1],ch1,sizeof(ch1));
            close(writepipe[1]);
    }
    else
    { //PARENT PROCESS
            close(writepipe[0]);
            close(writepipe[1]);
            ch="HI!! YOU THERE";
            write(readpipe[1],ch,sizeof(ch));
            close(readpipe[1]);
            read(writepipe[1],ch1,sizeof(ch1));
            printf("\nACK RECEIVED %s",ch1);
            close(writepipe[1]);
    }
    return 0;
}




C

Related
Uri/beecrowd problem no - 1099 solution in C Code Example Uri/beecrowd problem no - 1099 solution in C Code Example
c how to include variables of other c file Code Example c how to include variables of other c file Code Example
e sharm card jobkhozo.com Code Example e sharm card jobkhozo.com Code Example
3.Write a program that has a class student that stores roll number, name, and marks (in three subjects) of the students. Display the information (roll number, name, and total marks) stored ab 3.Write a program that has a class student that stores roll number, name, and marks (in three subjects) of the students. Display the information (roll number, name, and total marks) stored ab
ecto where is not nil Code Example ecto where is not nil Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8