Interprocess Communication Through Pipes

Hi everyone

The child process is a chess engine(stockfish), which you communicate using console normally.

I am trying to communicate with it through pipes. But when i attach the the write pipe the process gets terminated. Otherwise it is fine.

My question is when you create pipes to communicate with a process, should you give some sort of specific parameter for OS or should the child program be created specificly for this purpose? If not than this is a bug related to UE, most probably...

Here is the code, it is UE4 specific but still understandable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
	// Holds the URL of the executable to launch. */
	FString URL;

	// Holds the command line parameters. */
	FString Params;

	// Holds the handle to the process. */
	FProcHandle ProcessHandle;

	// Holds the read pipe. */
	void* ReadPipe;

	// Holds the write pipe. */
	void* WritePipe;

.
.
.

	if (!FPlatformProcess::CreatePipe(ReadPipe, WritePipe))
	{
		return false;
	}

	ProcessHandle = FPlatformProcess::CreateProc(*URL, *Params, false, bHidden, bHidden, nullptr, 0, nullptr, WritePipe);

	if (!ProcessHandle.IsValid())
	{
		UE_LOG(LogTemp, Warning, TEXT("Failed to launch"));
		return false;
	}
.
.
.

	FInteractiveProcess * StockFishProcess;
.
.
.
	FString tempPathToExecutable = FPaths::GameContentDir();
	tempPathToExecutable.Append(FString("stockfish-6-64.exe"));

	StockFishProcess = new FInteractiveProcess(tempPathToExecutable, FString(""), true);

	StockFishProcess->Launch();
Last edited on
I cannot (quickly) find Unreal docs for that particular function, but you need to make sure you are calling it exactly correctly. That asterisks are something of a red flag to me.

Also, I notice that you only specify WritePipe. What happened to ReadPipe?

Make sure you are connecting both the write and read pipes to the correct places:

  Your read handle connects to the spawned process's write handle
  Your write handle connects to the spawned process's read handle

I know nothing more about Unreal engine. If my advice is off then I suggest you ask over at the Unreal programming forums. https://forums.unrealengine.com/forumdisplay.php?9-C-Gameplay-Programming

Hope this helps.
Thank you for the answer @Duoas

I asked it at unreal forums. 7 days passed and noone answered yet. :(
https://forums.unrealengine.com/showthread.php?69922-Interactive-Process-Communication
By the way i share entire class at that page

I actually considered maybe i am doing something wrong, so checked Unreal github for example process-pipe creation, but this is the way they also used for process creation with pipes at Unreal Engine source.

Also before this i knew nothing about process communication. So at the moment i am looking at every little detail that has a possibility.

So my question is, when using pipes, is there specific requirements for the process or should i give specific parameters for OS?
Last edited on
I am asking silly questions, i should have some more confidence in me. Count my question in my previous post not asked
I hope Temaran has helped answer your question. I can answer questions about pipes and the like, but I cannot say anything more about Unreal Engine.
Temaran adviced to try some other methods.

But just out of curiosity i tried the same thing with Qt and it works quite well.

So now, i am certain this is a UE related bug and made a bug report for this :)
Topic archived. No new replies allowed.