/* -----------------------------------------------------------
C
C   NAME:
C        CSEND
C   PURPOSE:
C        This C function, starts the "jvsrun "C-shell script.
C
C---------------------------------------------------------- */

#include 
#include 
#include 
      
#define cmd "/home/user/bin/jvsrun"

void csend()
{
        pid_t res;
        int frnum,error,status;

        frnum = 0;
        printf("C says Frnum = %d\n",frnum);

        /* Forks a child process so hydrocode can continue simulation*/
        if ((res = fork())== -1) { 
           perror("fork failed");
        }

        /* If this is the child process then start jvsrun 
           else the parent process exits returning control
           to the hydrocode. */

  
        if (res == 0) {
          /* Start "jvsrun C-Shell script" */
          execl("/bin/sh","sh","-c",cmd, 0);

          /* Notify if the C-Shell script wasn't started properly */
          perror("exec for childprog failed");

          /* Wait until exec has finished before exiting C function "csend" */
          wait(&status);
        }
  
}