This site works best with JavaScript enabled
Sign In
Discussions
Activity
Sign In
All
Project.003: Linux System Programming
Issues, queries and suggestions related to Linux, Linux Programming, IPC, Interprocess Communication, Synchronization, Semaphore, System Programming, Linux Software Development.
Project.003: Linux System Programming
communication with pipe
iittashish447
March 2014
Today created pipe and communication between files are established.
ritug1992
October 2014
Implemented pipe to create connection between two different processes:
#include<stdio.h>
#include<unistd.h>
int main()
{
pid_t pid;
int arr[2],stat_val;
char ch[2],string[20];
if(pipe(arr))
{
perror("Creating pipe");
return -1;
}
printf("arr[0] is %d\n",arr[0]);
printf("arr[1] is %d\n",arr[1]);
gets(string);
write(arr[1],string,20);
pid = fork();
if(pid == 0)
{
printf("I am in child\n");
sprintf(ch,"%d",arr[0]);
execl("/home/ritu/emblogic/project_3/test_pipe",ch,NULL);
}
wait(&stat_val);
return 0;
}
test_pipe.c : // this process is called by the above process using execl call and pass fd for pipe to this process
#include<stdio.h>
int main(int argc , char * argv[])
{
char string[20];
int fd;
printf("fd received is %s\n",argv[0]);
fd = atoi(argv[0]);
read(fd,string,20);
printf("string read is %s",string);
return 0;
}
Add a Comment
Powered by
Vanilla
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
0
Module.101: Advanced Data Structures using C
17
Module.303: Linux System Programming
32
Project 22. Ethernet Network Device Driver Development
0
Project.14. Linux System and Network Administration
0
Project.10. Embedded Linux ARM, Configuring and Porting using Storage
0
Project.203 Linux System Programming. MySQL
0
Pravjot Sir Classes
114
Events at EmbLogic
2
Query
506
Module.000: Linux System Administration
24
Project.001: C Programming, Data Structures
78
Project.002: OOPs, C++, Eclipse, Linux
22
Project.003: Linux System Programming
34
Project.004: Linux Network Programming
8
Project.005: Character Device Drivers Development
21
Project.105: Parallel Port Device Drivers Development
5
Project.205: Serial Port Device Drivers Development
3
Project.008: Block Device Driver Development
3
Project.009: Embedded Linux-ARM. Storage
7
Module.011: Shell Scripting using Bash
6
Project 12: Linux Kernel Architecture and Internals
2
Project.015: Python with Eclipse on Linux
27
Project 16: SPI Device Driver Development
2
Project 17: I2C Device Driver Development
0
Project 18: PCI Device Driver Development
0
Project 19: Embedded Linux on ARM Using Network TFTP
0
Project 20: CAN Bus Protocol and Driver Development
0
Project 21: USB Device Drivers Development
0
Embedded Linux
0
ARM Embedded Processor
0
Training
2
Members Area
1
Word From Admin
1