You are on page 1of 5

RAHULEAL

Regmo. RAL9LO030 029


Setim- T
inckde <Adio k) jr )
t uoludo wid
9w a

Pd

oo p'pe 2uwusge [2] "helto"


Cho ead mumo-gL [LA]

um
eumAakus T)
plpelpipaa 29Tt
(ekumadakuy 2 ~a -1)

pld r e )
aelogerrbeldsito
ope Clpelds1

loAnppesmtursye),
wwbprt11) plpelunnae
gaud keadky m plpei
-MUKage
,peaduneq
clope peldatti3) 1orf

dose tpplads[
vead phelds s toa)'
pmu (A dld R ho p/pe Mnag1 i
yeowumege)
l t potOpyojungeseppe

ekm D,ils L ) p D

Ral ) J
Sulbrat
Ayush
myem
Sudas 6otlenauédett
olus
llgg monal ad Ble on the
ual",
atele/kue de

cat lenaua
E-cat Fi
h uo wude
cat 4te leD
fda t"#/R)
ht 6ah te 19
ig11T
el Ch t 1 a $h Ae 16
um 1 r

hoohod abauo

ewenu

etho go0d ulat


rii/,
Oupud-iv.,,

900 o oo

, rt
rahul@rhul-VirtualBox: -/Desktop

Btnclude<stdio.h>
#includecunistd . h>

tnt matn()_
int ptpefds[2]: _
Lnt returnstatus;
tnt p t d ;

char wrttenessages[2][20j-("Hi",
char readmessage[ 20]:
"Hello") ;

returnstatus ptpe(ptpefds):
if (returnstatus == -1)
prtntfunable to create ptpe\n")
return 1;

ptd fork() :
1I chtld process
Cptd = 0)
read(ptpefds[o]. readmessage. stzeof (readmessage)):
printr"child Process - Reading from ptpe - Message 1 ts *s\n", readmessa

9e)
read (ptpefds[o], readmessage, sizeof( readmessage)
printf("child Process - Reading from pipe - Message 2 is xs\n". readmessa

9e);
e l s e (1/Parent process
printf("Parent Process writing to ptpe - Message 1 ts xs\n", writemessa

w r t te (pipefds [1] . wrt tenessagesto]. sizeof(wri tenessages[ 01)):


rahulgrahul-virtualBoxx -/Desktop a
rahul@rahul-virtualBox :-/Desktop$ vt code2.c
rahul@rahul-VtrtualBOx:-/Desktops ./a.out
rahularahul-VirtuaLBox/DesktopS gcc code2.c
Parent Process
Process Hrltlng to ptpe Message 1 1s Ht
-

Parent_ Message 2 1 s Hello


Writtng to pipe - Message
chtld Process Reading H
chtld Process Reading from ptpe Message 21 is
from ptpe ts Hello
rahul@rahul-virtualBox: -/Desktop$|

You might also like