Search
 
SCRIPT & CODE EXAMPLE
 

C

pipe system call


#include <stdio.h>
#include <unistd.h>

int main()
{
    int pipeFds[2], status, pId;
    char writeMsg[20] = "hello world";
    char readMsg[20];

    status = pipe(pipeFds);

    if (status == -1)
    {
        printf("Unable to create pipe
");
        return 1;
    }

    pId = fork();

    // child process
    if (pId == 0)
    {
        read(pipeFds[0], readMsg, sizeof(readMsg));
        printf("
Child Process receives data
%s
", readMsg);
    }
    // parent process
    else if (pId > 0)
    {
        printf("Parent Process sends data
%s", writeMsg);
        write(pipeFds[1], writeMsg, sizeof(writeMsg));
    }

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: 2 html 1 javascript 
C :: pathlib exclude hidden file 
C :: how to declare an array of n numbers in c 
C :: type cast in c 
C :: cyrildewit laravel page view counter package. 
C :: count number of items using delimiter 
C :: spacemacs start server 
C :: C++ How to use enums for flags? 
C :: c fibonacci series recursion 
C :: fork 
C :: C #if, #elif and #else Directive 
C :: reset c array to zero 
C :: c ausgabe 
C :: 1 f = c 
C :: input multipal data types 
C :: Uri/Beecrowd Problem no - 1184 solution in C 
C :: python to java translator online 
C :: write a c program to find out ncr factor of given number 
C :: passing an array to a function 
C :: bash sed crop cut file line number 
C :: return multiple values using the call by reference 
C :: unconstrained box flutter 
C :: is 0 true or false 
C :: countoddevenDifference 
C :: Typecast Operator in C language 
C :: printf n characters c 
Dart :: list item bottom border in flutter 
Dart :: flutter listtile padding 
Dart :: bad state insecure http is not allowed flutter 
Dart :: how to get sha key in flutter 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =