mirror of
https://github.com/hexchat/hexchat.git
synced 2024-11-09 20:52:45 +01:00
make exec display as nice as possible
This commit is contained in:
parent
5d50ec01cb
commit
837557e9c7
@ -57,7 +57,7 @@ run_command (char *word[], char *word_eol[], void *userdata)
|
||||
strcpy (commandLine, "cmd.exe /c ");
|
||||
strcat (commandLine, word_eol[2]);
|
||||
|
||||
CreatePipe (&readPipe, &writePipe, &secattr, 0);
|
||||
CreatePipe (&readPipe, &writePipe, &secattr, 0); /* might be replaced with MyCreatePipeEx */
|
||||
|
||||
ZeroMemory (&sInfo, sizeof (sInfo));
|
||||
ZeroMemory (&pInfo, sizeof (pInfo));
|
||||
@ -67,7 +67,7 @@ run_command (char *word[], char *word_eol[], void *userdata)
|
||||
sInfo.hStdOutput = writePipe;
|
||||
sInfo.hStdError = writePipe;
|
||||
|
||||
CreateProcess (0, commandLine, 0, 0, TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, 0, 0, &sInfo, &pInfo);
|
||||
CreateProcess (0, commandLine, 0, 0, TRUE, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, 0, 0, &sInfo, &pInfo);
|
||||
CloseHandle (writePipe);
|
||||
|
||||
start = time (0);
|
||||
@ -77,17 +77,23 @@ run_command (char *word[], char *word_eol[], void *userdata)
|
||||
{
|
||||
if (ReadFile (readPipe, buffer, sizeof (buffer) - 1, &dwRead, NULL) && dwRead != 0 )
|
||||
{
|
||||
/* avoid garbage */
|
||||
buffer[dwRead] = '\0';
|
||||
xchat_printf (ph, "%s\n", buffer);
|
||||
xchat_printf (ph, "%s", buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this way we'll more likely get full lines */
|
||||
SleepEx (100, TRUE);
|
||||
}
|
||||
timeElapsed = difftime (time (0), start);
|
||||
}
|
||||
}
|
||||
|
||||
if (timeElapsed >= 10)
|
||||
{
|
||||
xchat_printf (ph, "Execution took too long, aborting.\n");
|
||||
xchat_printf (ph, "Command took too much time to run, execution aborted.\n");
|
||||
}
|
||||
|
||||
CloseHandle (readPipe);
|
||||
|
Loading…
Reference in New Issue
Block a user