TOPIC: CreatePipe issue
#1056
CreatePipe issue 2 Years, 8 Months ago
Hi

I thought this should be possible but I haven't had any luck so far:
I have CreatePipe
dll bool Kernel32:CreatePipe(handle read,handle write,SECURITY_ATTRIBUTES* lpProcessAttributes,long nSize)

To invoke I have tried:
CreatePipe(reader=Object() , writer=Object() , NULL, 512);
Errors out cannot convert Object to integer

CreatePipe(reader=NULL , writer=NULL , NULL, 512);
Access violation

CreatePipe(reader=-1 , writer=-1 , NULL, 512);
Access violation

Any ideas ?
thanks
z
 
 
#1057
Re:CreatePipe issue 2 Years, 8 Months ago
Partially fixed
dll bool Kernel32:CreatePipe(HANDLE* read,HANDLE* write,SECURITY_ATTRIBUTES* lpProcessAttributes,long nSize)

Appears to work with HANDLE struct {long h}

But now the program launched with CreateProcess crashes (with a stackdump), and it is a direct result of setting the stdin/out values...

Yawn ..

:unsure:

Post edited by: zippy, at: 2007/12/11 10:42
 
 
#1059
Re:CreatePipe issue 2 Years, 8 Months ago
Sorry for the slow response, I was out of town.

Have you looked at the source for RunPiped (runpiped.cpp)? It might give you some clues.
 
 
andrew
 
#1060
Re:CreatePipe issue 2 Years, 8 Months ago
Thanks andrew !
that function does almost exactly what I want to do..

The only difference is I want to run the process in the background (the processes will take a long time) and not block the UI

Ill see what I can dig from it.
 
 
#1061
Re:CreatePipe issue 2 Years, 8 Months ago
I must be missing something, see anything wrong with this ? The same command works perfectly using the runpiped command. All prints show true but the program immediately stack faults.
Code:


security=Object(nLength:'SECURITY_ATTRIBUTES.Size(),
 lpSecurityDescriptor:NULL,
 bInheritHandle:true
 );

Print("stdout",CreatePipe(stdoutreader = Object(), stdoutwriter = Object() , security, 0));
SetHandleInformation(stdoutreader.hnd,.HANDLE_FLAG_INHERIT,0)

Print("stdin",CreatePipe(stdinreader = Object(), stdinwriter = Object() , security, 0));
SetHandleInformation(stdinwriter.hnd,.HANDLE_FLAG_INHERIT,0)

processinformation = Object(
hProcess:0
hThread:0
dwProcessId:0
dwThreadId:0
)

startup = Object(cb:'STARTUPINFO.Size(),
lpReserved:0,
lpDesktop:0,
lpTitle:'ss',
dwX:0,
dwY:0,
dwXSize:100,
dwYSize:410,
dwXCountChars:0,
dwYCountChars:0,
dwFillAttribute:0,
dwFlags:0x100,
wShowWindow:1,
cbReserved2:0,
lpReserved2:NULL,
hStdInput:'stdinreader.hnd,
hStdOutput:'stdoutwriter.hnd,
hStdError:'stdoutwriter.hnd
)

command = 'cdrtoolsmkisofs.exe -o test2.iso -Jr -V Session2 c:/temp/temp'

r = CreateProcess(NULL, command, NULL, NULL,
true,
0, // 0x08000000, // CREATE_NO_WINDOW
NULL,
NULL,
startup,
processinformation)
Print("Process started ?", r)

CloseHandle(processinformation.hProcess);
CloseHandle(processinformation.hThread);

CloseHandle(stdinreader.hnd);
CloseHandle(stdoutwriter.hnd);

 
 
#1062
Re:CreatePipe issue 2 Years, 8 Months ago
It looks reasonable. I assume the CreatePipe calls are succeeding.

Does the CreateProcess work if you don't redirect stdin and stdout?

You mentioned you didn't want to wait for the process to finish. In this case is it safe to close the handles right away?
 
 
andrew
 
#1063
Re:CreatePipe issue 2 Years, 8 Months ago
Hi

Yes the create pipes are succeeding and the createprocess does work if the dwflags are set to 0. I had a waitforsingleobject call in before the close handles but it made no difference, It almost appears like the STARTUPINFO may be structured incorrectly but I havent had any luck adjusting it either.

z