~zorba-coders/zorba/bug-1210410-process

« back to all changes in this revision

Viewing changes to src/process-2.xq.src/process.cpp

  • Committer: Zorba Jenkins
  • Author(s): Nicolae Brinza
  • Date: 2013-07-10 15:09:31 UTC
  • mfrom: (33.2.19 process-2)
  • Revision ID: jenkins@lambda.nu-20130710150931-cw285a6elb6kf16y
Changed module's errors to the new modules guidelines; Potential fix for execvpe() on Macs
Approved: Ghislain Fourny, Nicolae Brinza

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
{
54
54
  extern char **environ;
55
55
  char **saved = environ;
56
 
  int rc;
57
56
  environ = envp;
58
 
  rc = execvp(program, argv);
 
57
  int rc = execvp(program, argv);
59
58
  environ = saved;
60
59
  return rc;
61
60
}
105
104
  wsprintf(lErrorBuffer,TEXT("Process Error Code: %d - Message= %s"),GetLastError(), (TCHAR *)lpvMessageBuffer);
106
105
  LocalFree(lpvMessageBuffer);
107
106
  Item lQName = ProcessModule::getItemFactory()->createQName(
108
 
    "http://www.zorba-xquery.com/modules/process",
109
 
    "PROC01");
 
107
    "http://zorba.io/modules/process", "COMMUNICATION");
110
108
#ifdef UNICODE
111
109
  char error_str[1024];
112
110
  WideCharToMultiByte(CP_UTF8, 0, lErrorBuffer, -1, error_str, sizeof(error_str), NULL, NULL);
239
237
      || !CreatePipe(&lErrRead,&lStdErr,&lSecurityAttributes,1024*1024) // std::cerr >> lErrRead
240
238
    ){
241
239
    Item lQName = ProcessModule::getItemFactory()->createQName(
242
 
      "http://www.zorba-xquery.com/modules/process", "PROC01");
 
240
      "http://zorba.io/modules/process", "COMMUNICATION");
243
241
    throw USER_EXCEPTION(lQName,
244
242
      "Couldn't create one of std::cout/std::cerr pipe for child process execution."
245
243
    );
261
259
      lErrorMsg 
262
260
        << "Couldn't get exit code from child process. Executed command: '" << aCommand << "'.";
263
261
      Item lQName = ProcessModule::getItemFactory()->createQName(
264
 
        "http://www.zorba-xquery.com/modules/process", "PROC01");
 
262
        "http://zorba.io/modules/process", "COMMUNICATION");
265
263
      throw USER_EXCEPTION(lQName, lErrorMsg.str().c_str());
266
264
    }
267
265
  
451
449
    std::stringstream lErrorMsg;
452
450
    lErrorMsg << "Failed to execute the command (" << code << ")";
453
451
    Item lQName = ProcessModule::getItemFactory()->createQName(
454
 
      "http://www.zorba-xquery.com/modules/process", "PROC01");
 
452
      "http://zorba.io/modules/process", "COMMUNICATION");
455
453
    throw USER_EXCEPTION(lQName, lErrorMsg.str().c_str());
456
454
  }
457
455
  exit_code = code;
489
487
      std::stringstream lErrorMsg;
490
488
      lErrorMsg << "Failed to execute the command (" << pid << ")";
491
489
      Item lQName = ProcessModule::getItemFactory()->createQName(
492
 
            "http://www.zorba-xquery.com/modules/process", "PROC01");
 
490
            "http://zorba.io/modules/process", "COMMUNICATION");
493
491
      throw USER_EXCEPTION(lQName, lErrorMsg.str().c_str());
494
492
      return NULL;
495
493
    }
515
513
      std::stringstream lErrorMsg;
516
514
      lErrorMsg << "Failed to close the err stream (" << status << ")";
517
515
      Item lQName = ProcessModule::getItemFactory()->createQName(
518
 
        "http://www.zorba-xquery.com/modules/process", "PROC01");
 
516
        "http://zorba.io/modules/process", "COMMUNICATION");
519
517
      throw USER_EXCEPTION(lQName, lErrorMsg.str().c_str());
520
518
    }
521
519
 
528
526
        std::stringstream lErrorMsg;
529
527
        lErrorMsg << "Failed to wait for child process ";
530
528
        Item lQName = ProcessModule::getItemFactory()->createQName(
531
 
          "http://www.zorba-xquery.com/modules/process", "PROC01");
 
529
          "http://zorba.io/modules/process", "COMMUNICATION");
532
530
        throw USER_EXCEPTION(lQName, lErrorMsg.str().c_str());          
533
531
    }
534
532