Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: Win32command
I am executing cmd.exe commands via a C program with the CreateProcess function. I check to see if cmd.exe has terminated with the GetExitCodeProcess function, by checking to see if the process exit code equals anything except STILL_ACTIVE. This works fine with commands like "cmd /c echo Hello World", but for commands like "cmd /c dir c:\test", cmd.exe will never terminate if the directory contains more than 60 entries, cmd.exe will terminate if there are 60 or less entries in the directory. Does anyone know why it behaves like this? Thanks a lot.
Posted 15-Dec-12 2:58am
Edited 15-Dec-12 3:02am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Apparently I have to start to read the stdout/stderr pipe in the loop which checks to see if the process is still running, as well as read it after the process has terminated. Rather than just read it after the process has terminated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
0 Guruprasad.K.Basavaraju 490
1 Sergey Alexandrovich Kryukov 316
2 Shai Vashdi 264
3 OriginalGriff 250
4 praveen_07 115
0 Sergey Alexandrovich Kryukov 9,185
1 OriginalGriff 5,315
2 Peter Leow 4,040
3 Maciej Los 3,535
4 Abhinav S 3,308

Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 15 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid