Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 2.2. Есть ли данные на STDOUT дочернего процесса ?
- BZERO(buf);
- if (0 == PeekNamedPipe(
- read_stdout, buf, BUFSIZE - 1, &bread, &avail, NULL))
- {
- printf("\nPeekNamedPipe() fails with error: %i", GetLastError());
- break;
- }
- if (bread > 0)
- {
- // ReadFile() может прочитать меньше, чем есть в STDOUT дочернего
- // процесса, необходимо организовать цикл, чтобы прочитать все данные.
- left = bread;
- idx = 0;
- while (left > 0)
- {
- if (0 == (res = ReadFile(
- read_stdout, &buf[idx], left, &received, NULL)))
- {
- printf("\nReadFile() fails with error: %i", GetLastError());
- break;
- }
- if(res && (received == 0))
- break; // EOF
- left -= received;
- idx += received;
- }
Advertisement
Add Comment
Please, Sign In to add comment