Hello,
I have another a problem while writing to child and then reading the result:

Code:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int main()
{
        char    buf[5];
        int     fd[2],
                c;
        pipe(fd);
        if(fork() == 0)
        {
                dup2(fd[1], 1); //stdout -> pipe's write (everything what would go to stdout will go to the pipe's write...
                execlp("sort", "sort", NULL);
        }

        write(fd[1], "c\n", 2);
        write(fd[1], "a\n", 2);
        write(fd[1], "b\n", 2);

        while((c = read(fd[0], buf, 5)) > 0)
                write(1, buf, c);

        return  0;
}
In the child process I redirect stdout of the process to the pipe's write. So when I read in the parent's process I should have a sorted list but I receive not sorted and what is more, the program doesn't ends.
Regards,
apacz