Home » NO IDEA » IPC using pipes

IPC using pipes

Blog Stats

  • 15,880 hits
April 2013
M T W T F S S
« Mar   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  

#include<unistd.h>
#include<stdio.h>
int main()
{
int fd[3],pid;
char *msg=("OS LAB\n");
char buff[25];
pipe(fd);
pid=fork();
if(pid==0)
{
puts("child process\n");
close(fd[0]);
write(fd[1],msg,30);
}
else
{
sleep(1);
puts("parent process\n");
close(fd[1]);
read(fd[0],buff,30);
printf("%s",buff);
}
return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: