void executeMainClass()

in src/main/cpp/launcher/windows/src/Launcher.c [683:739]


void executeMainClass(LauncherProperties * props) {
    if(isOK(props) && !isTerminated(props)) {
        int64t * minSize = newint64_t(0, 0);
        writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Executing main class", 1);
        checkFreeSpace(props, props->tmpDir, minSize);
        if(isOK(props)) {
            HANDLE hErrorRead;
            HANDLE hErrorWrite;
            char * error = NULL;
            
            CreatePipe(&hErrorRead, &hErrorWrite, NULL, 0);
            hideLauncherWindows(props);
            executeCommand(props, props->command, NULL, INFINITE, props->stdoutHandle, hErrorWrite, NORMAL_PRIORITY_CLASS);
            if(!isOK(props)) {
                writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... an error occured during JVM running main class", 1);
                props->exitCode = props->status;
            } else {
                char * s = DWORDtoCHAR(props->exitCode);
                writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... main class has finished its work. Exit code is ", 0);
                writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, s, 1);
                FREE(s);
            }
            
            error = readHandle(hErrorRead);
            if(getLengthA(error)>1) {
                DWORD showMessage = 0;
                char * ptr = error;
                while(ptr!=NULL) {
                    //Bug #105165 and #194242
                    if((searchA(ptr, "Picked up ") == NULL && searchA(ptr, "fatal: Not a git repository") == NULL) && getLengthA(ptr) > 1) {
                        showMessage = 1;
                        break;
                    }
                    ptr = searchA(ptr, "\n");
                    if(ptr!=NULL) ptr++;
                }
                
                if(showMessage && props->exitCode != 0) {
                    WCHAR * errorW = toWCHAR(error);
                    showMessageW(props, getI18nProperty(props, JAVA_PROCESS_ERROR_PROP), 1, errorW);
                    FREE(errorW);
                } else {
                    writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, error, 1);
                }
            }
            CloseHandle(hErrorWrite);
            CloseHandle(hErrorRead);
            FREE(error);
            Sleep(1);
        } else {
            props->status = ERROR_FREESPACE;
            props->exitCode = props->status;
            writeMessageA(props, OUTPUT_LEVEL_DEBUG, 1, "... there is not enough space in tmp dir to execute main jar", 1);
        }
        FREE(minSize);
    }
}