Diff for /parser3/src/main/pa_exec.C between versions 1.35 and 1.37

version 1.35, 2002/04/16 09:38:49 version 1.37, 2002/07/11 08:16:24
Line 27 Line 27
 #ifdef WIN32  #ifdef WIN32
   
 /// this func from http://www.ccas.ru/~posp/popov/spawn.htm  /// this func from http://www.ccas.ru/~posp/popov/spawn.htm
 static BOOL WINAPI CreateHiddenConsoleProcess(LPCTSTR szCmdLine,  static DWORD CreateHiddenConsoleProcess(LPCTSTR szCmdLine,
                                                                                 char *szEnv,                                                                                  char *szEnv,
                                         PROCESS_INFORMATION* ppi,                                           PROCESS_INFORMATION* ppi, 
                                         LPHANDLE phInWrite,                                          LPHANDLE phInWrite,
                                         LPHANDLE phOutRead,                                          LPHANDLE phOutRead,
                                         LPHANDLE phErrRead)                                          LPHANDLE phErrRead)
 {  {
     BOOL fCreated;      DWORD result=0;
           BOOL fCreated;
     STARTUPINFO si;      STARTUPINFO si;
     SECURITY_ATTRIBUTES sa={0};      SECURITY_ATTRIBUTES sa={0};
     HANDLE hInRead;      HANDLE hInRead;
Line 88  static BOOL WINAPI CreateHiddenConsolePr Line 89  static BOOL WINAPI CreateHiddenConsolePr
                               dir,                                dir,
                               &si,                                &si,
                               ppi);                                ppi);
           if(!fCreated)
                   result=GetLastError();
   
     CloseHandle(hInRead);      CloseHandle(hInRead);
     CloseHandle(hOutWrite);      CloseHandle(hOutWrite);
Line 96  static BOOL WINAPI CreateHiddenConsolePr Line 99  static BOOL WINAPI CreateHiddenConsolePr
     if(!fCreated)      if(!fCreated)
         goto error;          goto error;
   
     return TRUE;      return result;
   
 error:  error:
           if(!result/*yet*/)
                   result=GetLastError(); // get it
   
     CloseHandle(*phInWrite);      CloseHandle(*phInWrite);
     CloseHandle(*phOutRead);      CloseHandle(*phOutRead);
     CloseHandle(*phErrRead);      CloseHandle(*phErrRead);
   
     return FALSE;      return result;
 }  }
   
 static void read_pipe(String& result, HANDLE hOutRead, const char *file_spec,   static void read_pipe(String& result, HANDLE hOutRead, const char *file_spec, 
Line 136  static const char *buildCommand(Pool& po Line 142  static const char *buildCommand(Pool& po
                                         string.APPEND_AS_IS(begin, end-begin,                                           string.APPEND_AS_IS(begin, end-begin, 
                                                 origin_string.origin().file, 0);                                                  origin_string.origin().file, 0);
                                         string << " " << file_spec_cstr;                                          string << " " << file_spec_cstr;
                                         if(argv)  
                                                 for(int i=0; i<argv->size(); i++)  
                                                         string << argv->get_string(i)->cstr();  
                                         result=string.cstr();                                          result=string.cstr();
                                 }                                  }
                         }                          }
Line 330  int pa_exec( Line 333  int pa_exec(
                 env->for_each(append_env_pair, &string);                  env->for_each(append_env_pair, &string);
                 env_cstr=string.cstr();                  env_cstr=string.cstr();
         }          }
         if(CreateHiddenConsoleProcess(cmd, env_cstr, &pi, &hInWrite, &hOutRead, &hErrRead)) {          if(DWORD error=CreateHiddenConsoleProcess(cmd, env_cstr, &pi, &hInWrite, &hOutRead, &hErrRead)) {
                   char szErrorDesc[MAX_STRING];
                   char *param="the file you tried to run";
                   size_t error_size=FormatMessage(
                           FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ARGUMENT_ARRAY , NULL, error,
                           MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
                           szErrorDesc, sizeof(szErrorDesc), &param);
                   if(error_size>3) // ".\r\n"
                           szErrorDesc[error_size-3]=0;
               
                   throw Exception(0,
                           &file_spec,
                           "exec failed - %s (%ld). Consider adding shbang line (#!x:\\interpreter\\command line)", 
                                   error_size?szErrorDesc:"<unknown>", (long)error);
           } else {
                 const char *in_cstr=in.cstr();                  const char *in_cstr=in.cstr();
                 DWORD written_size;                  DWORD written_size;
                 WriteFile(hInWrite, in_cstr, in.size(), &written_size, NULL);                  WriteFile(hInWrite, in_cstr, in.size(), &written_size, NULL);
Line 351  from http://www.apache.org/websrc/cvsweb Line 368  from http://www.apache.org/websrc/cvsweb
 */        */      
                 CloseHandle(pi.hProcess);                  CloseHandle(pi.hProcess);
         CloseHandle(pi.hThread);          CloseHandle(pi.hThread);
         } else {  
                 DWORD error=GetLastError();  
                 char szErrorDesc[MAX_STRING];  
                 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error,  
                 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),  
                 szErrorDesc, sizeof(szErrorDesc), NULL);  
                 size_t error_size=strlen(szErrorDesc);  
                 if(error_size>3) // ".\r\n"  
                         szErrorDesc[error_size-3]=0;  
               
                 throw Exception(0,  
                         &file_spec,  
                         "(real command line=\"%s\") exec failed - %s (%ld)",  
                                 cmd,  
                                 szErrorDesc, (long)error);  
         }          }
   
 #else  #else

Removed from v.1.35  
changed lines
  Added in v.1.37


E-mail: