Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Race condition when setting TERM{,INFO{,_DIRS}}



Hi,

Half a year after submitting a patch to treat TERMINFO_DIRS like TERMINFO and TERM, I now see a race condition in handling these vars.

Zsh handles these variables specially because ncurses looks for them in the environment of the current process. To make changes to these variables apply to zsh itself, they are exported to the process environment, where ncurses can find them.

But there is a possible race condition between exporting these vars (setenv) and refreshing the ncurses handle (getent). In my case, when TERMINFO_DIRS is set from /etc/zshenv, the new value is ignored by ncurses.
The same applies to the subsequent TERM=$TERM in /etc/zshenv.

However, if I add a delay before TERM=$TERM, then the TERMINFO_DIRS update is seen, and the terminal is properly detected.

Could it be that there are threads involved in zsh ?
This seems really weird because the code looks sequential.

Any hint welcome.

-- Layus



Messages sorted by: Reverse Date, Date, Thread, Author