Remove not used libraries and macros.
[wsti_so.git] / src / process3.c
1 #include <stdio.h>
2
3 /* open/read/write/close */
4 #include <fcntl.h>
5
6 /**
7  * Program grabs data (calculated number of characters) from process2 and prints
8  * grabbed data to the standard output.
9  */
10 int main(void) {
11         /** Named pipe used to communicate with process2 */
12         char * read_pipe = "/tmp/process2pipe";
13
14         int read_descriptor;
15         
16         int buffer = 0;
17         
18         int i = 0;
19         ssize_t count = 0;
20
21         /* Reading from process2 */
22         read_descriptor = open(read_pipe, O_RDONLY);
23
24         int number_of_characters = 0;
25         
26         while(1) {
27                 /* Read data from input pipe */
28                 count = read(read_descriptor, &buffer, sizeof(int));
29
30                 fprintf(stderr, "[%s] Fetched: %d bytes\n", "process3", count);
31
32                 if (count > 0) {
33                         fprintf(stderr, "[%s] Process2 send: %d\n", "process3", buffer);
34                 }
35                 else {
36                         break;
37                 }
38         }
39
40         close(read_descriptor);
41
42         return 0;
43 }