mafredri / zsh-async

Because your terminal should be able to perform tasks asynchronously without external tools!
MIT License
766 stars 34 forks source link

prevent infinite loop in case of broken zpty file descriptor #31

Closed symphorien closed 5 years ago

symphorien commented 5 years ago

In some cases, the fd created by zpty can become corrupted: if the other end was disconnected, if the fd was closed and so on. If we ignore this condition, then we enter a infinite loop. This eats 100% of a cpu and is very annoying.

Instead, when the fd becomes invalid, this commit unregisters the corresponding worker and notifies the callback. The error code was chosen to be "[async]" because the readme mentions this is how some existing errors are already notified to callbacks.

I have discovered this problem as part of the pure prompt. This happens randomly about once a week. I have been using this fork for some time, now, and the problem has disappeared.

The tests still pass.

symphorien commented 5 years ago

The ci build failure seems spurious to me. Please tell me if there is something to fix.

symphorien commented 5 years ago

Regarding pure, when this is merged, I will do a pull request to pure to take this failure mode into account.

mafredri commented 5 years ago

Oh, that's awesome. Looking forward to it, and thanks again for this 😄.