WritePipe does not work with exe process

I am having trouble with the FPlatformProcess::WritePipe() function.

I have:
Created a pipe FPlatformProcess::CreatePipe(readPipe, writePipe)
Created my process PlatformProcess::CreateProc(*url, *params, false, false, false, processID, 0, nullptr, writePipe) - Works

I can read from my pipe and get feedback from the exe program: FPlatformProcess::ReadPipe(readPipe) - Works

Every time I write with the WritePipe() function it returns true, but It does not reflect on the exe.
FString* out = new FString();
if (!FPlatformProcess::WritePipe(writePipe, command, out))
{
return false;
}

Has anyone tried using this method before?

Note this exe works with C# StreamWriter.WriteLine(string)

You’re probably well past this by now but I was having the same issue (so this is for others facing this issue). I decided to read the Microsoft docs, since the underlying code is just calling the Windows API (on windows).

I was able to get this working by following the standard Windows API:

// Handles
void* StdOutReadHandle = nullptr;
void* StdOutWriteHandle = nullptr;
void* StdInReadHandle = nullptr;
void* StdInWriteHandle = nullptr;

// In/Out pipes
FPlatformProcess::CreatePipe(StdOutReadHandle, StdOutWriteHandle);
FPlatformProcess::CreatePipe(StdInReadHandle, StdInWriteHandle, true);

FProcHandle ProcHandle = FPlatformProcess::CreateProc("path/to/my.exe", "args", true, true, true, nullptr, 0, nullptr, StdOutWriteHandle, StdInReadHandle);

FPlatformProcess::WritePipe(StdInWriteHandle, "Hello, World!");
3 Likes

that’s because when you create the pipe, you only create the pipe that transmit data from outer process to UE, but didn’t create a pipe that transmit data from ue to outer process.So you may want to do as Brent do, which is creating another pipe, and give the readHandle to the process when creating it.

but I don’t think the issue has anything to do with Windows underlying code

I wonder why the second CreatePipe needs bWritePipeLocal = true.