TobiasChe / conemu-maximus5

Automatically exported from code.google.com/p/conemu-maximus5
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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/9006f4942a3820f0478fdc597580d76dc09
1c90a

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);

Original issue reported on code.google.com by rick.sla...@gmail.com on 22 Dec 2013 at 5:58

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by ConEmu.Maximus5 on 22 Dec 2013 at 1:22

GoogleCodeExporter commented 9 years ago

Original comment by ConEmu.Maximus5 on 24 Dec 2013 at 8:21