-
Notifications
You must be signed in to change notification settings - Fork 26
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
Minimise calls to lookupEnv / getenv #166
Comments
However, as |
One could argue that a well-designed application should call |
I was thinking there were only two handles that needed to be checked: |
Not really, any handle can be a terminal or a pseudo-terminal device. On UNIX any shell session is a terminal device represented as a file in |
Thanks @mpilgrem! |
This is reflected in |
I'm trying to mitigate UnkindPartition/tasty#326. The underlying problem is that Setenv is not Thread Safe, so if one thread calls
setEnv
for any environmental variable and another one callshSupportsANSI
(which executeslookupEnv "TERM"
under the hood) the application segfaults.This is of course not a fault of
ansi-terminal
at all, but rather a general issue with POSIX standard. Nevertheless it would be helpful to minimize number of calls tolookupEnv
. How about adding a top-levellookupEnvTerm
as below?And then
This way
lookupEnv "TERM"
will be executed at most once, even ifhSupportsANSI
is called multiple times. IMO this is safe: we do not really care if our application itself at some points modified its environment withsetEnv
- this could not change the properties of the terminal.The text was updated successfully, but these errors were encountered: