Click here to Skip to main content
12,999,010 members (47,118 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i m in the start of C, Linux ... may u help me please how can i create 4 Process and Piping a message in c Linux?

process1 give the result by pipe1 to process2 ... process 2 by pipe2 send the result to process3 then process3 give the result to process4 by pipe3 and process4 save the result into a file..

wait for ur kind answers...
many thanks
Posted 1-Dec-12 17:54pm
You range is amazing. Now, didn't you expect traditional question: what did you try?
@AmitGajjar 2-Dec-12 1:41am
at least you should respect when someone helping you without any expectation. what will you loss if you reply him nicely ?
lida zar 2-Dec-12 1:52am
i did ... but he again and again discuss with me about own myself ... when i tried very much on google and etc ... how can i solve it lonely ... and also sergey make me upset ... instead of help me to solve my problem ... only review my questions and my knowledge ... yes my knowledge isn't good like him or other one which manage here ... im only a simple student and trying to stand on my own ... then i really don't know why he do joking with me ( a girl) ?
@AmitGajjar 2-Dec-12 2:31am
it's not like that. when your parents punish they are not doing joking with you, they actually try to teach you something. SA want you to learn yourself. everyone phase the same student life. but if you will not try something yourself, you always need someone's help.

But one golden rule to learn is "never get upset when you fail in your work"

best luck.
lida zar 2-Dec-12 2:40am
ok thanks anyways ... i surrender!
@AmitGajjar 2-Dec-12 6:42am
its good to see you understand at this level.
lida zar 2-Dec-12 6:47am
my IQ is working now :)) thanks ..
Golden words, Amit!
Don't surrender and don't get upset. Just realize that I give you a good advice.
Now, I know you are a girl, but what's wrong with joking with you? I call it sexism. We all have equal rights and should be treated equally, OK? Let's not go wrong way...
lida zar 2-Dec-12 14:59pm
@AmitGajjar 2-Dec-12 22:57pm
thank you.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Its for only 3 processes :-
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#define MSGSIZE    14 
char *message = "hello, world!"; 
main() { 
char inbuf[MSGSIZE];
int p[3];
pid_t pid;
pid_t pid1;
if (pipe(p) == -1){ 
perror("pipe call"); 

pid = fork();
pid1 = fork();

if(pid == -1){
perror("Fork failed");
if(pid | pid1 == 0)//process A
    write(p[1], message, MSGSIZE);
    read(p[1], message, MSGSIZE);
    write(p[2], message, MSGSIZE);
/*else if(pid1 == 0){
    //read(p[1], message, MSGSIZE);
    write(p[2], message, MSGSIZE);

    //parent process C
    read(p[0], inbuf, MSGSIZE);
    printf("Pipelined message return:%s\n", inbuf);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170622.1 | Last Updated 2 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100