hey fellas, i typically ask all my ?s on gentoo's forums (my distro) but this needs a larger brain pool i think than i can get over there. i'm trying to write a client/server-ish type traceroute utility that will give round trip traceroute information. since i'm not interested in customizing traceroute anymore than it already is capable of, using the /bin/traceroute binary seems to be a good option as well since this will only be used on a couple linux boxes around the country.

the idea is to have the program run with an IP address passed as an arg, initiate the traceroute output the information to the console that traceroute *ip via arg*, then signal the targeted machine to basically do the same thing but send the traceroute information back via tcp or something for the client to display, to get full traversasl information. its a project i've been tasked with, not like i dream of this at night.

anyways here's the code i've started with from the pipe man

Code:
#include <sys/wait.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/*
The  following  program  creates  a pipe, and then fork(2)s to create a
child process.  After the fork(2), each process closes the  descriptors
that  it  doesn't  need  for  the  pipe (see pipe(7)).  The parent then
writes the string contained in the program's command-line  argument  to
the  pipe,  and  the  child reads this string a byte at a time from the
pipe and echoes it on standard output.
*/
int main(int argc, char *argv[])
{
	int pfd[2];
        pid_t cpid;
        char buf;

        assert(argc == 2);

        if (pipe(pfd) == -1) 
        {
		perror("pipe"); 
		exit(EXIT_FAILURE); 
	}

        cpid = fork();
        
	if (cpid == -1)
	{
	perror("fork");
	exit(EXIT_FAILURE);
	}

        if (cpid == 0) {    /* Child reads from pipe */
            close(pfd[1]);          /* Close unused write end */
  
            while (read(pfd[0], &buf, 1) > 0)
               write(STDOUT_FILENO, &buf, 1);

	    execl("/bin/traceroute", argv[1], (char *) 0);

            write(STDOUT_FILENO, "\n", 1);
            close(pfd[0]);
            _exit(EXIT_SUCCESS);

        } 
	
	else {            /* Parent writes argv[1] to pipe */
            close(pfd[0]);          /* Close unused read end */
            write(pfd[1], argv[1], strlen(argv[1]));
            close(pfd[1]);          /* Reader will see EOF */
            wait(NULL);             /* Wait for child */
            exit(EXIT_SUCCESS);
        }
}
there are chunks of this code i just don't understand...but from what i have researched i need to create a fork to get a new process space w/ new PID, fork to that process, run traceroute with the arg originally passed, and pipe the output from that program back to the parent process. i'm just not sure how, or at least where to do that.

anyone mind maybe editing the code above and give me a framework to work with, maybe j ust some comments of where to do what and i can research how to do it? the fork exec and pipe is all i need help with. i can do the networking myself