| 2934 | } |
| 2935 | |
| 2936 | void CShellProc::OnCreateProcessFinished(BOOL abSucceeded, PROCESS_INFORMATION *lpPI) |
| 2937 | { |
| 2938 | // logging |
| 2939 | { |
| 2940 | const size_t cchLen = 255; |
| 2941 | wchar_t szDbgMsg[cchLen]; |
| 2942 | if (!abSucceeded) |
| 2943 | { |
| 2944 | msprintf(szDbgMsg, cchLen, |
| 2945 | L"Create(ParentPID=%u): Failed, ErrCode=0x%08X", |
| 2946 | GetCurrentProcessId(), GetLastError()); |
| 2947 | } |
| 2948 | else |
| 2949 | { |
| 2950 | msprintf(szDbgMsg, cchLen, |
| 2951 | L"Create(ParentPID=%u): Ok, PID=%u", |
| 2952 | GetCurrentProcessId(), lpPI->dwProcessId); |
| 2953 | if (WaitForSingleObject(lpPI->hProcess, 0) == WAIT_OBJECT_0) |
| 2954 | { |
| 2955 | DWORD dwExitCode = 0; |
| 2956 | GetExitCodeProcess(lpPI->hProcess, &dwExitCode); |
| 2957 | const int len = lstrlen(szDbgMsg); |
| 2958 | msprintf(szDbgMsg+len, cchLen-len, |
| 2959 | L", Terminated!!! Code=%u", dwExitCode); |
| 2960 | } |
| 2961 | } |
| 2962 | LogShellString(szDbgMsg); |
| 2963 | } |
| 2964 | |
| 2965 | BOOL bAttachCreated = FALSE; |
| 2966 | |
| 2967 | if (abSucceeded) |
| 2968 | { |
| 2969 | CShellProc::mn_LastStartedPID = lpPI->dwProcessId; |
| 2970 | |
| 2971 | // ssh-agent.exe is intended to do self-fork to detach from current console |
| 2972 | if (lpPI->dwProcessId && !ms_ExeTmp.IsEmpty() && IsSshAgentHelper(ms_ExeTmp)) |
| 2973 | { |
| 2974 | CESERVER_REQ* pIn = ExecuteNewCmd(CECMD_SSHAGENTSTART, sizeof(CESERVER_REQ_HDR)+sizeof(DWORD)); |
| 2975 | if (pIn) |
| 2976 | { |
| 2977 | pIn->dwData[0] = lpPI->dwProcessId; |
| 2978 | CESERVER_REQ* pOut = ExecuteGuiCmd(ghConWnd, pIn, nullptr); |
| 2979 | ExecuteFreeResult(pOut); |
| 2980 | ExecuteFreeResult(pIn); |
| 2981 | } |
| 2982 | } |
| 2983 | |
| 2984 | if (gnAttachPortableGuiCui && gnServerPID) |
| 2985 | { |
| 2986 | CESERVER_REQ* pIn = ExecuteNewCmd(CECMD_PORTABLESTART, sizeof(CESERVER_REQ_HDR)+sizeof(CESERVER_REQ_PORTABLESTARTED)); |
| 2987 | if (pIn) |
| 2988 | { |
| 2989 | pIn->PortableStarted.nSubsystem = mn_ImageSubsystem; |
| 2990 | pIn->PortableStarted.nImageBits = mn_ImageBits; |
| 2991 | _ASSERTE(wcschr(ms_ExeTmp,L'\\')!=nullptr); |
| 2992 | lstrcpyn(pIn->PortableStarted.sAppFilePathName, ms_ExeTmp, countof(pIn->PortableStarted.sAppFilePathName)); |
| 2993 | pIn->PortableStarted.nPID = lpPI->dwProcessId; |
no test coverage detected