Processes and Windows handles question
Roger.Riggs at Oracle.com
Mon Sep 21 22:09:10 UTC 2015
I have a problem that could benefit from more Windows expertise than I
The proposal to use NIO Pipes to provide Selectable Channels as Peter
Levert proposed in 
works fine on Linux. On Windows, it seems to work ok when the output of
the process is
handled as a channel but there is an anomaly when trying to use a
Channel to send input to the process.
The NIO Pipe implemention on Windows conveniently uses a Socket to
localhost: for the Pipe.
The handles for the underlying ends of the socket are appropriately sent
to the CreateProcess API
when the process is created.
But the child processes produce errors such as:
cat: -: Bad Address
or bad parameter
I suspect that the child process is trying to read from the socket
handle using an ordinary
In the other direction in which the output from the child is written to
the network socket seem to work ok.
But I'm not sure if it is reliable.
Suggestions welcome on ways to setup the Socket so it would work or
As Peter proposed, using Selectable channels is optional depending on
and OS combinations. The easy way out is to just say Channels do not
work for sending
input to a process on Windows.
More information about the core-libs-dev