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!");
1 Like