zsh-async
zsh-async copied to clipboard
Consider moving away from zpty if possible
I just came across a method for implementing async in zsh that doesn't require the zpty module. Take a look at this commit in zsh-autosuggestions: https://github.com/zsh-users/zsh-autosuggestions/pull/338
Not sure if it will work with zsh-async, but wanted to pass it along in case it might simplify things.
Thanks for the suggestion! I have considered this method in the past, but the reasons for abandoning it escape me. (At least one reason is that I did not know about zle -F at the time.)
zsh-async does have some requirements that could be challenging using this approach:
- Long running worker with multiple jobs/tasks running
- (Reason for this is I've wanted to avoid the overhead of forking, the worker forks once and waits for jobs)
- The worker needs to be able to terminate its jobs (this is done by sending a kill to the workers process group to ensure termination of all processes started by the jobs)
- Not sure if a requirement, but at least it will not be possible to run applications (or run them in a mode) that expect the stdout to be connected to a terminal
IIRC there is also some difference in behavior between read and zpty -r (latter being more reliable) that might have affected this decision in the past. Although, this might not be relevant here.
Anywho, I'll take this up for consideration, and maybe experiment with it when I have some dead time 😄.