Changeset 16066

Show
Ignore:
Timestamp:
07/22/08 00:23:39 (5 years ago)
Author:
saturday06
Message:

cygwin系

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/cplusplus/i3/src/Test.cpp

    r16064 r16066  
    113113    } 
    114114 
    115     if (PathAppend(fakecygpty,"misc") == FALSE) { 
    116         mol_abort(); 
    117     } 
    118  
    119     if (PathAppend(fakecygpty,"fakecygpty.exe") == FALSE) { 
     115    if (_tcscat_s(fakecygpty, _T("\\misc\\fakecygpty.exe")) == EINVAL) { 
    120116        mol_abort(); 
    121117    } 
     
    125121    { 
    126122        HKEY hkResult = NULL; 
    127         TCHAR SubKey[] = _T("SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/"); 
     123        const TCHAR SubKey[] = _T("SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/"); 
    128124        LONG result2 = RegOpenKeyEx(HKEY_LOCAL_MACHINE, SubKey, 0, KEY_EXECUTE, &hkResult); 
    129125        if (result2 != ERROR_SUCCESS) { 
     
    149145    // �p�C�v�֘A 
    150146    SECURITY_ATTRIBUTES sa = {}; 
     147    sa.bInheritHandle = TRUE; 
     148 
    151149    STARTUPINFO si = {}; 
    152150    PROCESS_INFORMATION pi = {}; 
    153     HANDLE hStdOutput = NULL; 
    154     HANDLE hStdError = NULL; 
    155     HANDLE hStdInput = NULL; 
    156  
    157     //sa.bInheritHandle = TRUE; 
    158     CreatePipe(&hStdInput, &hStdOutput, &sa, NULL); 
     151 
     152    HANDLE hStdInput    = NULL; 
     153    HANDLE hStdOutput   = NULL; 
     154    HANDLE hStdError    = NULL; 
     155    HANDLE hMyStdInput  = NULL; 
     156    HANDLE hMyStdOutput = NULL; 
     157    HANDLE hMyStdError  = NULL; 
     158 
     159    CreatePipe(&hStdInput    , &hMyStdInput , &sa, NULL); 
     160    CreatePipe(&hMyStdOutput , &hStdOutput  , &sa, NULL); 
     161    CreatePipe(&hMyStdError  , &hStdError   , &sa, NULL); 
     162 
     163    // �n���h���̃A�N�Z�X���ύX 
     164    if (!DuplicateHandle(GetCurrentProcess(),hMyStdInput ,GetCurrentProcess(),NULL, 0, FALSE, DUPLICATE_SAME_ACCESS) || 
     165        !DuplicateHandle(GetCurrentProcess(),hMyStdOutput,GetCurrentProcess(),NULL, 0, FALSE, DUPLICATE_SAME_ACCESS) || 
     166        !DuplicateHandle(GetCurrentProcess(),hMyStdError ,GetCurrentProcess(),NULL, 0, FALSE, DUPLICATE_SAME_ACCESS)) { 
     167 
     168        BOOST_REQUIRE(false); 
     169    } 
     170 
    159171    si.cb = sizeof(STARTUPINFO); 
    160172    si.dwFlags = STARTF_USESTDHANDLES; 
    161 //    si.hStdInput = hStdInput; 
    162     si.hStdInput  = GetStdHandle(STD_INPUT_HANDLE); 
     173 
     174    si.hStdInput = hStdInput; 
    163175//    si.hStdOutput = hStdOutput; 
     176//    si.hStdError  = hStdError; 
     177 
     178//    si.hStdInput  = GetStdHandle(STD_INPUT_HANDLE); 
    164179    si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); 
    165     si.hStdError  = GetStdHandle(STD_ERROR_HANDLE ); 
    166  
    167     cout << "fakecygpty: [" << fakecygpty << "]" << endl 
    168          << "cd: [" << cd << "]" << endl; 
    169  
    170     BOOL result4 = CreateProcess(fakecygpty, _T("fakecygpty /bin/zsh"), NULL, NULL, TRUE, 0, NULL, cd, &si, &pi); 
     180    si.hStdError  = GetStdHandle(STD_ERROR_HANDLE); 
     181 
     182    BOOL result4 = CreateProcess(fakecygpty, _T("fakecygpty /bin/zsh --login -i"), NULL, NULL, TRUE, 0, NULL, cd, &si, &pi); 
    171183    BOOST_CHECK(result4 != 0); 
    172184 
    173     Sleep(10000); 
    174 } 
     185    DWORD written = 0; 
     186    { 
     187        const char output[] = "source ~/.i3\n"; 
     188        WriteFile(hMyStdInput, output, sizeof(output), &written, NULL); 
     189    } 
     190    { 
     191        const char output[] = "/bin\t\t"; 
     192        WriteFile(hMyStdInput, output, sizeof(output), &written, NULL); 
     193    } 
     194    { 
     195        //const char output[] = "\003"; 
     196        //WriteFile(hMyStdInput, output, sizeof(output), &written, NULL); 
     197    } 
     198 
     199 
     200    Sleep(3000); 
     201    CloseHandle(hStdInput); 
     202    CloseHandle(hStdOutput); 
     203    CloseHandle(hStdError); 
     204    CloseHandle(hMyStdInput); 
     205    CloseHandle(hMyStdOutput); 
     206    CloseHandle(hMyStdError); 
     207}