Allow lisp programs to read a process's stdout and stderr either separately or together. #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was trying to get a language server running in lem (clangd) but it was not starting. After some investigation I found that clangd was outputing error messages to stderr, which were being piped to stdout via the PTY in async-process.
I ended up having to rewrite all of async-process.c in order to add this ability in. Apparently PTYs only have in input stream and an output stream. My solution was to add a second PTY into the process just for stderr. This should work fine as long as programs don't try to set terminal settings on stderr, as these settings will not be mirrored to the PTY running stdout and stdin.
These changes still need some testing before they can be merged. I need to ensure that there are no memory leaks, either in the C code or in the CL interface. One of the changes I made was to use dynamically allocated buffers for read. This way a single call through the CFFI will read as much data as it can. We can revisit this decision if a thinner C API is desired. I am marking this PR as a draft for the time being.
also note, that I changed the load path for libasyncprocess.so to where it is saved to on my local machine for testing