Click here to Skip to main content
13,457,409 members
Rate this:
Please Sign up or sign in to vote.
See more:
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
Updated 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180322.1 | Last Updated 15 Dec 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100