void SetUpTwoWayPipe ( const char *cmd )
 {
    int to_child[2];  /* pipe descriptors from parent->child */
    int to_parent[2]; /* pipe descriptors from child->parent */
   int   pid;
   fprintf(stderr,"pipe1\n");
   pipe ( to_child );
   pipe ( to_parent ); 

    if ( pid = fork (), pid == 0 )     /* in the child   */
    {
        close ( 0 );                    /* redirect stdin */
        dup ( to_child[0] );
        close ( 1 );                    /* redirect stdout*/
        dup ( to_parent[1] );

        close ( to_child[0] );          /* close pipes    */
        close ( to_child[1] );
        close ( to_parent[0] );
        close ( to_parent[1] );
        fprintf(stderr,"%s execute \n",cmd);
        execlp ( cmd, cmd, NULL );      /* exec the new cmd */
        /*system(cmd);*/
    }
    else if ( pid > 0 )                /* in the parent  */
    {
        close ( 0 );                    /* redirect stdin */
        dup ( to_parent[0] );
        close ( 1 );                    /* redirect stdout  */
        dup ( to_child[1] );

        setbuf ( stdout, NULL );        /* no buffered output */

        close ( to_child[0] );          /* close pipes */
        close ( to_child[1] );
        close ( to_parent[0] );
        close ( to_parent[1] );
    }
    else                                /* error!       */
    {
        fprintf ( stderr,"Couldn't fork process %s\n", cmd );
exit ( 1 );
	}
}
