This codes creating pipe for IPC, fork another process (child) and executing fortune with some cookies arguments. It also redirect child's stdout to it's writer pipe to be read by parent's pipe. exec() family calls never return except for errors, if this happen it is very bad ;p. exec() will replace it's calling process with a new image, since the kernel is not know where to continue after invoking exec() then the child just exit. Just to make sure you don't write codes after that exec() except for error checking, don't care how cool your codes, it just not work. Trust me heh?.
http://pastebin.com/raw.php?i=pceQuWjc