You do not have aliasing issues. Here the only issue I see is read(fd_pipe[0], buf, sizeof(node))
, this should be read(fd_pipe[0], buf, sizeof(Node *))
.
I am not sure why you use a char buffer here, I prefer
Node *node;
if (read(fd_pipe[0], &node, sizeof(node)) <= 0) {
// error, deal with it
}
It's simpler and clearer.
Now, your code will only work as is if you use blocking i/o which is the default. Also, technically, you should handle short read/writes but writing/reading on a pipe is atomic if the read/written size is less than PIPE_BUF (which is always much larger than a pointer)
You have a bit of a grey area in your code about memory synchronization before the write but since this is a system call, it will work.
A pipe is an unusual way to communicate between threads. Usually, people use in-memory queues to communicate between threads. One example is http://www.boost.org/doc/libs/1_53_0/doc/html/boost/lockfree/queue.html