Skip to main content

Write a program to create a child process in which child process displays number of line sent by parent process.


#include
#include
#include
#include
#include

main(int agrc,char *argv[])
{
    int fd[2],pid,line=0,n;
    char buffer[2048]="Milind Audichya\Dhruv Naik\Uzer Pathan\n",buffer2[1];

    if(pipe(fd)==-1)
    {
        printf(" problem to create the pipe \n ");
        exit(0);
    }
    else
    {
        pid=fork();

        if(pid!=0)
        {
            printf("Perent Send Data To Chlid Data is:- %s ",buffer);
            close(fd[0]);
            write(fd[1],buffer,strlen(buffer));
            close(fd[1]);
        }
        else
        {
            close(fd[1]);
            printf("Chlid Process Read The Content send by the Perent.");
            while((n=read(fd[0],buffer2,1)) == 1)
            {
                if(buffer2[0] == '\n')
                {
                    line++;
                }
            }
            printf("Number of line send by Perent:-%d",line);
            close(fd[0]);
        }

    }
}

Comments

Popular posts from this blog

Quiz 1 : Mobile Application Development - Android

Download PDF Version From Here   MCQ 1. Select a component which is NOT part of Android architecture. a. Android framework   b. Libraries          c. Linux kernel   d. Android document 2. What is AAPT? a. Android Asset Processing Tool.             b. Android Asset Providing Tool.   c. Android Asset Packaging Tool.             d. Android Asset Packaging Technique 3. Required folder when Android project is created. a. build                 b. build/               c. bin     d. bin/ 4. Adb stands for   A. Android Drive Bridge.                  ...

Never try to go back and repair the past which is impossible. But be prepared to construct the future which is possible.

Never try to go back and repair the past which is impossible. But be prepared to construct the future which is possible.

Give yourself more #freedom today, open up to your #greatness just a little bit more. Your #wings are aching to fly!

Give yourself more #freedom today, open up to your #greatness just a little bit more. Your #wings are aching to fly! Find some more lovely walls on our android application.. Download Now : https://play.google.com/ store/apps/ details?id=com.milindaudich ya.milindsquotecollection