Removing socket-based control connections for inter-process communication
In the beginning, Warlock use PIPES for inter-process communication. Namely STDIN, STDOUT and STDERR. This worked perfectly on Linux/Unix machines, but developing on Windows machines was required and Windows has some serious issues with PIPES. The main issue is that they DO NOT work in non-blocking mode, meaning Warlock could not operate correctly. The other symptom of this was that data returned from a child process would not reach the parent until the pipe was closed and the process ended, meaning bi-directional real-time communication was not possible using PIPES on Windows.
So I switched to using TCP sockets for the control channel, but they appear to be pretty unreliable under PHP. Possibly due to some sort of resource management going on when the socket resource is lefts un-used for some time. This is most pronounced when the child process is doing some long-running task without communicating with the parent, so PHP seems to shut down the socket but doesn't notify the program until it attempts to use the socket. And then it notifies the program with a FATAL error and shuts it down.
Because of all this, I will be going back to using PIPES for inter-process communications and essentially ditching support for running Warlock on Windows.
HOWEVER!!!!
Windows 10 now has a cool feature called Windows Sub-system for Linux, which allows linux programs to run inside a Linux shell. I have already tested this and been able to start Warlock from a Windows CMD prompt using the included vendor binaries by executing the command:
wsl vendor/bin/warlock
From within a project folder. This should take care of windows development while allowing me to write code specifically tailored for Linux systems and achieve greater reliability and performance.