Skip to content
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

47358: Add a ZSH_XTRACEFD environment variable to redirect debug traces #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pawamoy
Copy link
Member

@pawamoy pawamoy commented Feb 27, 2024

Just opening for code review purposes. Patches must be sent by email to the zsh-workers mailing list. Ref of previous discussions around ZSH_XTRACEFD: 47358 (for example see https://www.zsh.org/mla/workers//2020/msg01177.html).

@pawamoy
Copy link
Member Author

pawamoy commented Feb 27, 2024

Initially opened there by mistake: zsh-users#113 (cross-referencing in case there's activity over there as well).

@pawamoy
Copy link
Member Author

pawamoy commented Mar 1, 2024

Interesting comments:

https://www.zsh.org/mla/workers/2020/msg00611.html

The problem is if we fopen() the file descriptor to use stdio as output, we can either
leak the entire FILE, not opened by the user, or we can close the entire FILE.

In that case we should be doing the fopen() on a dup() of the
descriptor, and fclose()ing the FILE.

If it is important that fileno(xtrerr) == $ZSH_XTRACEFD, then we should

  1. dup() the descriptor to save a copy
  2. fopen() the original
  3. after fclose(), dup2() the copy back to the original
  4. close() the copy

However, I'm not sure it's necessary to be that convoluted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant