Click here to Skip to main content
12,818,688 members (28,679 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ C Windows Win32 Driver CLI

I have a parent process that starts a child process, who then writes to its inherited stdout handle.

Perhaps think of the parent process as a cygwin shell and the child process as nano or something. I want to monitor the input / output of nano. Cygwin doesn't necessarily see the output of nano, as it could just write to its inherited stdout handle, writing to a console directly.

Solution 1: Don't let the child process inherit its stdout handle

Parent process creates an anonymous pipe, sets child process's output handle to the input handle of the pipe and starts a thread that reads from the pipe and writes to stdout, one character at a time.

I think this would be problematic for control characters and things like command line text editors that use console position. All that stuff would get nerfed.

For example, all these console functions wouldn't work:

Please correct me if I'm wrong.

Solution 2: Monitor child process's stdout handle via some sort of filter driver

There are some great tutorials on File System filter drivers. My understanding is these will only catch stuff that actually goes to file.

So, is there some way to catch all writes to given handle?

One of those File System Filter Drivers with a couple tweaks?

Minifilter driver?

Is there some other driver stack I should be looking at?


Any suggestions or comments are appreciated. Anything at all!
Posted 31-Dec-13 13:55pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Solution 1 works as long as the child process doesn't manipulate the console API directly.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Well, not always. Processes behave differently if they intend to write to console. ftp.exe, for example will just not write anything (except errors) if it can't WriteConsole.

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 | Mobile
Web01 | 2.8.170308.1 | Last Updated 24 Feb 2014
Copyright © CodeProject, 1999-2017
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