Skip to content

Conversation

@ethanxxxl
Copy link

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

@cxxxr
Copy link
Member

cxxxr commented Jan 14, 2026

That's great.
If it doesn't break the behavior of existing lem features, I'd like to merge it.

@ethanxxxl
Copy link
Author

currently chasing a bug with process_write, for large inputs (greater than ~11.7k bytes) the program will fail to transfer all the data, and then lock up, with a "Resource temporarily unavailable" error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants