X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fprocess3.c;fp=src%2Fprocess3.c;h=d5be26a12c2088dfe48748cb46ed1785757e5ae1;hb=05e20db49d95955f0f00f546a7d02e4df023b805;hp=0000000000000000000000000000000000000000;hpb=eb58b0955c4340aafb4508e9c269b3216b2c1c1f;p=wsti_so.git diff --git a/src/process3.c b/src/process3.c new file mode 100644 index 0000000..d5be26a --- /dev/null +++ b/src/process3.c @@ -0,0 +1,48 @@ +#include +#include +#include + +/* open/read/write/close */ +#include + +/** If buffer is too small to hold entire string, it is incremented by this value */ +#define BUFFER_STEP 16 + +/** + * Program grabs data from process1, calculates number of characters in each line + * and pass the value to process3. + */ +int main(void) { + /** Named pipe used to communicate with process1 */ + char * read_pipe = "/tmp/process2pipe"; + + int read_descriptor; + + int buffer = 0; + + int i = 0; + ssize_t count = 0; + + /* Reading from process2 */ + read_descriptor = open(read_pipe, O_RDONLY); + + int number_of_characters = 0; + + while(1) { + /* Read data from input pipe */ + count = read(read_descriptor, &buffer, sizeof(int)); + + fprintf(stderr, "[%s] Fetched: %d bytes\n", "process3", count); + + if (count > 0) { + fprintf(stderr, "[%s] Process2 send: %d\n", "process3", buffer); + } + else { + break; + } + } + + close(read_descriptor); + + return 0; +} \ No newline at end of file