Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipe Read fails on Azure

I have a legacy application that I am trying to run under an Azure worker. The application uses a fairly common pattern to launch a child process by creating an anonymous pipe, redirecting stdout to the pipe, spawning a child process, then using the pipe to communicate.

To get this to run under Azure, I make a P/Invoke call to the dll that starts this whole process.

All of this works fine outside of Azure, but fails even when running under the emulator.

When running under Azure, the procs are unable to communicate over the pipe. Specifically, the call to read on the handle to the pipe by the parent is failing (timeout).

like image 553
AdamC Avatar asked Dec 10 '25 02:12

AdamC


1 Answers

I finally figured out that the problem was because the legacy code was duplicating the stdout handle to pass to the child process.

Running under Azure, GetStdHandle for STDOUT was returning 0x0. This means basically, "No error, but you don't have a STDOUT". Apparently, you need to check for 0x0 AND INVALID_HANDLE.

Creating the handles, setting them on the STARTUPINFO before starting the child instead of duplicating the existing ones fixed everything up.

like image 57
AdamC Avatar answered Dec 12 '25 16:12

AdamC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!