1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Beep cut short???

Discussion in 'Plugins' started by vefatica, Jul 30, 2010.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,063
    Likes Received:
    30
    Rex, I have a plugin ALERT which executes a command upon console output, waiting at least a specified time between alerts. It works well except when the command piped to it finishes quickly.

    This happens in my plugin:

    Code:
    while ( ReadFile(hIn, inBuf, 16384, &dwRead, NULL) && dwRead != 0 )
    {
        WriteFile(hOut, inBuf, dwRead, &dwRead, NULL);
        if ( (dwThisTime = GetTickCount()) > dwNextTime )
        {
            dwNextTime = dwThisTime + 1000 * dwWait;
            CreateThread(NULL, 0, CommandThread, pCommand, 0, NULL);
        }
    }
    The thread simply executes the command:

    Code:
    DWORD WINAPI CommandThread ( LPVOID pCommand )
    {
        WCHAR    szCommand[4096];
    
        lstrcpy(szCommand, (WCHAR*) pCommand);
    
        Command((WCHAR*) szCommand, 0);
    
        return 0;
    }
    When I call it like this (5 is the minimum wait):

    Code:
    echo foo | alert 5 beep 440 3
    the beep is cut short when the prompt reappears. I would have thought that impossible and it doesn't happen if I BEEP any of the system sounds. Can you tell me what's happening?
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,063
    Likes Received:
    30
    Never mind. I get it. The process running my plugin command (in a pipe) is exiting taking with it whatever notification might be in progress.
     

Share This Page