Maximus5 / conemu-old-issues

Old issues imported from googlecode. Project was moved to
https://conemu.github.io
6 stars 1 forks source link

Starting process directory not respected when program uses alternate screen buffers #1402

Closed Maximus5 closed 9 years ago

Maximus5 commented 9 years ago

Originally reported on Google Code with ID 1402

OS version: Win7  SP1   x64
ConEmu version: 131219 x64
Far version (if you are using Far Manager): none

*Bug description*
Processes started under ConEmuC that use CreateConsoleScreenBuffer/SetConsoleActiveScreenBuffer
have their current working directory warped to the folder containing the program executable.

*Steps to reproduction*
1. Compile and run the test screen buffer program sb.c (attached), e.g. cl /Zi sb.c
2. Change directory to C:\
3. Run the sb.exe program from where it was built
4. Observe the program's reported current directory at startup
5. Running the test outside of ConEmu results in C:\
6. Running the test under ConEmu results in folder that contains sb.exe

Proposed commit to fix the bug:

https://github.com/ricksladkey/ConEmu/commit/9006f4942a3820f0478fdc597580d76dc091c90a

Proposed patch to src/ConEmuCD/ConsoleMain.cpp:

diff --git a/src/ConEmuCD/ConsoleMain.cpp b/src/ConEmuCD/ConsoleMain.cpp
index 57679a5..628cd84 100644
--- a/src/ConEmuCD/ConsoleMain.cpp
+++ b/src/ConEmuCD/ConsoleMain.cpp
@@ -1497,7 +1497,7 @@ int __stdcall ConsoleMain2(int anWorkMode/*0-Server&ComSpec,1-AltServer,2-Reserv
    /* ************************ */

    // ×òîáû íå áëîêèðîâàòü ïàïêó çàïóñêà
-   if (szSelfDir[0])
+   if (gnRunMode != RM_ALTSERVER && szSelfDir[0])
        SetCurrentDirectory(szSelfDir);

    if (gnRunMode == RM_SERVER)
@@ -1625,7 +1625,7 @@ wait:

    // ×òîáû íå áëîêèðîâàòü ïàïêó çàïóñêà (íà âñÿêèé ñëó÷àé, åñëè íà ìåòêó goto áûë)
-   if (szSelfDir[0])
+   if (gnRunMode != RM_ALTSERVER && szSelfDir[0])
        SetCurrentDirectory(szSelfDir);

Reported by rick.sladkey on 2013-12-22 05:58:31


Maximus5 commented 9 years ago

Reported by ConEmu.Maximus5 on 2013-12-22 13:22:00

Maximus5 commented 9 years ago

Reported by ConEmu.Maximus5 on 2013-12-24 08:21:49