The console cancels the application

I start the socket server on my server, and I woke up to numerous messages about its inaccessibility. It turns out that before I went to bed, I highlighted the IP address in the window and forgot to press Enter to resume the process.

Here's how to turn off the selection in the console now, but I still want to be able to choose without pausing the application.

    #region Disable Quick-Edit Mode
    [DllImport("kernel32.dll")]
    static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode);

    [DllImport("kernel32.dll")]
    static extern bool GetConsoleMode(IntPtr hConsoleHandle, out int mode);

    [DllImport("kernel32.dll")]
    static extern IntPtr GetStdHandle(int handle);

    const int STD_INPUT_HANDLE = -10;
    const int ENABLE_EXTENDED_FLAGS = 0x80;

    public static void DisableQuickEditMode()
    {
        int mode;
        IntPtr handle = GetStdHandle(STD_INPUT_HANDLE);
        GetConsoleMode(handle, out mode);
        mode |= ENABLE_EXTENDED_FLAGS;
        SetConsoleMode(handle, mode);
        mode &= ~ENABLE_QUICK_EDIT;
        SetConsoleMode(handle, mode);
    }

Legacy Mode Command Prompt, ( ), , . , Enter , , , , . , , ; "" "". , .

+4
1

Windows stdout stderr. , .

, , .

, : . , stdout stderr Windows tail ( , Sublime, ).

server.exe > server.log 2>&1

: 2>&1 , stderr ( 2) " " stdout ( 1).

+5
source

Source: https://habr.com/ru/post/1659635/


All Articles