Beep cut short???

May 20, 2008
Syracuse, NY, USA
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:

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:

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

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?
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.