Click here to Skip to main content
15,914,410 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Temporary pointer Pin
Michael Dunn6-Oct-06 18:59
sitebuilderMichael Dunn6-Oct-06 18:59 
QuestionCan't get a file path from a windows dialog and pass it too a directX api call Pin
BarryOg6-Oct-06 14:11
BarryOg6-Oct-06 14:11 
AnswerRe: Can't get a file path from a windows dialog and pass it too a directX api call Pin
Hamid_RT6-Oct-06 19:20
Hamid_RT6-Oct-06 19:20 
GeneralRe: Can't get a file path from a windows dialog and pass it too a directX api call Pin
BarryOg7-Oct-06 1:38
BarryOg7-Oct-06 1:38 
GeneralRe: Can't get a file path from a windows dialog and pass it too a directX api call Pin
Hamid_RT7-Oct-06 2:48
Hamid_RT7-Oct-06 2:48 
GeneralRe: Can't get a file path from a windows dialog and pass it too a directX api call Pin
BarryOg7-Oct-06 4:09
BarryOg7-Oct-06 4:09 
QuestionwaveOutGetID [modified] Pin
kk30036-Oct-06 11:51
kk30036-Oct-06 11:51 
QuestionCreateProcess() anomaly Pin
neilsolent6-Oct-06 9:21
neilsolent6-Oct-06 9:21 
Mad | :mad: Confused | :confused: Dead | X|

Hi everyone

I am running the following piece of code on Windows 2000 and XP (except the code below has been simplified with error checking removed).
This code spawns a child process, which writes its output to a logfile called child.log.

The problem I am having is: if the child process is a command or batch file (example below), then child.log captures output of commands such as "dir",
however, for any processes that are launched from the batch script, such as perl.exe, all the output is lost. I don't know where the
output is going or why. I suspect I have done something wrong with handle inheritance somewhere.. any ideas??
I don't get the same problem if the child process is some other shell interpreter, such as bash.exe.

.........................

SECURITY_ATTRIBUTES secAttr;
secAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
secAttr.bInheritHandle = TRUE;
secAttr.lpSecurityDescriptor = NULL;

STARTUPINFO startupInfo;
::ZeroMemory((void*) &startupInfo, sizeof(STARTUPINFO));
startupInfo.cb = sizeof(STARTUPINFO);
startupInfo.dwFlags = STARTF_USESTDHANDLES;

PROCESS_INFORMATION processInfo;

startupInfo.hStdOutput = CreateFile(
"child.log",
GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,
&secAttr,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
startupInfo.hStdError = startupInfo.hStdOutput;

CreateProcess(
NULL,
"test.bat",
NULL,
NULL,
TRUE,
DETACHED_PROCESS,
NULL,
NULL,
&startupInfo,
&processInfo);

// Close handle because parent process has no further need for it:
CloseHandle(startupInfo.hStdOutput);


..................

Example of test.bat:
----------------------------

rem test.bat
rem dir command gives output in child.log, but "perl -v" does not !!

dir
perl -v
exit 0



cheers,
Neil
QuestionAuthFilt always display the logon page Pin
Will88888886-Oct-06 8:49
Will88888886-Oct-06 8:49 
QuestionImage sequence display in Dialog [modified] Pin
Bighand20006-Oct-06 7:22
Bighand20006-Oct-06 7:22 
AnswerRe: Image sequence display in Dialog Pin
led mike6-Oct-06 8:44
led mike6-Oct-06 8:44 
GeneralRe: Image sequence display in Dialog Pin
Bighand20006-Oct-06 9:19
Bighand20006-Oct-06 9:19 
AnswerRe: Image sequence display in Dialog Pin
Hamid_RT6-Oct-06 8:48
Hamid_RT6-Oct-06 8:48 
GeneralRe: Image sequence display in Dialog [modified] Pin
Bighand20006-Oct-06 9:22
Bighand20006-Oct-06 9:22 
GeneralRe: Image sequence display in Dialog Pin
Hamid_RT6-Oct-06 19:00
Hamid_RT6-Oct-06 19:00 
GeneralRe: Image sequence display in Dialog Pin
Bighand20007-Oct-06 4:29
Bighand20007-Oct-06 4:29 
GeneralRe: Image sequence display in Dialog Pin
Hamid_RT7-Oct-06 6:54
Hamid_RT7-Oct-06 6:54 
GeneralRe: Image sequence display in Dialog Pin
Bighand20007-Oct-06 16:52
Bighand20007-Oct-06 16:52 
GeneralRe: Image sequence display in Dialog Pin
Hamid_RT7-Oct-06 19:52
Hamid_RT7-Oct-06 19:52 
GeneralRe: Image sequence display in Dialog Pin
Bighand200010-Oct-06 11:55
Bighand200010-Oct-06 11:55 
GeneralRe: Image sequence display in Dialog Pin
Hamid_RT10-Oct-06 18:43
Hamid_RT10-Oct-06 18:43 
GeneralRe: Image sequence display in Dialog [modified] Pin
Bighand200021-Oct-06 15:37
Bighand200021-Oct-06 15:37 
GeneralRe: Image sequence display in Dialog Pin
Hamid_RT22-Oct-06 1:28
Hamid_RT22-Oct-06 1:28 
QuestionElegant solution for alignment Pin
Andre xxxxxxx6-Oct-06 7:10
Andre xxxxxxx6-Oct-06 7:10 
AnswerRe: Elegant solution for alignment Pin
led mike6-Oct-06 8:39
led mike6-Oct-06 8:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.