-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InputOutputLocalProcess
limitations: can't distinguish "no data available" and "subprocess terminated"; no way to query exit code
#5676
Comments
I think this is (a little poorly) explained in the documentation -- when reading from a program, This isn't easily fixable without breaking backwards compatability. If we changed |
O. k., but then the manual example is at least misleading, it should better show how one can get reliable output. |
I think the current implementation of iostream is fundamentally limited making it difficult if not impossible to use safely in general. The first issue that immediately comes to mind is this: InstallMethod(IsEndOfStream, "iostream",
[IsInputOutputStreamByPtyRep and IsInputOutputStream],
stream -> # stream![4] or
IS_BLOCKED_IOSTREAM(stream![1]) ); plus that: static Obj FuncIS_BLOCKED_IOSTREAM(Obj self, Obj stream)
{
UInt pty = HashLockStreamIfAvailable(stream);
int isBlocked = (PtyIOStreams[pty].blocked || PtyIOStreams[pty].changed ||
!PtyIOStreams[pty].alive);
HashUnlock(PtyIOStreams);
return isBlocked ? True : False;
} So as far as I can tell (I may have missed something!) there is no way to distinguish between an actual "end of stream" (the child process terminated), versus "there is no data right now but there soon might be" versus some other event. Of course we could (and probably should) improve this by adding additional But even then there are limitations to what we can do... Sure, it should be sufficient for "simple" communications where all messages between GAP and the subprocess are short, everything is fine: you write your message out all at once; it nicely fits into the OS buffers and so the subprocess can read it, process it, and then writes its answer in one go, and we read it all at once. But already for What is missing is something akin to POSIX This is indeed more problematic for things like e.g. coset enumeration were a tiny input can lead to gigantic output. There we need to rely on e.g. markers in the output to know when it is complete. So something like But for arbitrary programs this doesn't work (there are no end markers). Dunno what to do there. But maybe I am worrying about this needlessly. @ThomasBreuer do you have a concrete application in mind? |
@fingolfin No, I do not need |
Here is another thing that seems broken or at least missing in As a result, as far as I know, it is impossible to see if such a subprocess signaled an error or not. That makes it impossible to (safely) use for various applications. Right now I encountered this in the |
InputOutputLocalProcess
InputOutputLocalProcess
limitations: can't distinguish "no data available" and "subprocess terminated"; no way to query exit code
When playing with the manual example for
InputOutputLocalProcess
(see #5673 for the background),I noticed that the results are not reliable. The following happens in the current master branch.
First define a function that executes the lines of the manual example.
Then call this function enough often.
When I remove the first two
#
characters from the function, I even get the following.What is going on here?
The text was updated successfully, but these errors were encountered: