An assignment in my Operating Systems class requires me to build a binary process tree by recursively calling exec on the same program. The goal is to split some arbitrary task
As Jonathon Reinhart says you should change this lines:
char *argv2[] = {"some random arg to make sure that argc == 2 in the child", NULL};
execvp("two_way_pipes", argv2);
to:
char *argv2[] = {argv[0], "some random arg...", NULL};
execvp(argv[0], argv2);
then it works as expected:
echo test | ./two_way_pipes
in parent | message received: test
In your program you wrote "two_way_pipes" but it is not in your PATH so you really need the extra ./ so argv[0] then is ("./two_way_pipes").