Logo Search packages:      
Sourcecode: csound version File versions  Download package

PUBLIC long csoundRunCommand ( const char *const *  argv,
int  noWait 

Runs an external command with the arguments specified in 'argv'. argv[0] is the name of the program to execute (if not a full path file name, it is searched in the directories defined by the PATH environment variable). The list of arguments should be terminated by a NULL pointer. If 'noWait' is zero, the function waits until the external program finishes, otherwise it returns immediately. In the first case, a non-negative return value is the exit status of the command (0 to 255), otherwise it is the PID of the newly created process. On error, a negative value is returned.

Definition at line 121 of file threads.c.

References csoundRunCommand().

Referenced by csoundRunCommand().

    long    retval;

    if (argv == NULL || argv[0] == NULL)
      return -1L;
    retval = (long) fork();
    if (retval == 0L) {
      /* child process */
      if (execvp(argv[0], (char**) argv) != 0)
      /* this is not actually reached */
    else if (retval > 0L && noWait == 0) {
      int   status = 0;
      while (waitpid((pid_t) retval, &status, 0) != (pid_t) ECHILD) {
        if (WIFEXITED(status) != 0) {
          retval = (long) (WEXITSTATUS(status)) & 255L;
          return retval;
        if (WIFSIGNALED(status) != 0) {
          retval = 255L;
          return retval;
      retval = 255L;
    return retval;

Generated by  Doxygen 1.6.0   Back to index