Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ZSH performance regression in 5.8.1.2-test
- X-seq: zsh-workers 50107
- From: "Jun. T" <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: ZSH performance regression in 5.8.1.2-test
- Date: Tue, 26 Apr 2022 23:31:37 +0900
- Archived-at: <https://zsh.org/workers/50107>
- In-reply-to: <CAH+w=7bb+3T5MabhmCS9BwC7XmTxmydxQ5GLy7R7+6f6B7-=EA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAHDOzW6wE2aP6-MMrBNAUYttzQwi2VC_OY7tJDwkQwrtp47zEQ@mail.gmail.com> <CAH+w=7YwV=Cu1N7dSb417R1Q0vAMu6R6hAryXqE4RBkmU_w5gA@mail.gmail.com> <20220425192036.p6awbyro2a2lp7bq@chazelas.org> <CAH+w=7Yz-usT3nbbOW8o-awgZ_EKYVDaM_VVhyKYwaiOdxRzzw@mail.gmail.com> <CAH+w=7bb+3T5MabhmCS9BwC7XmTxmydxQ5GLy7R7+6f6B7-=EA@mail.gmail.com>
> 2022/04/26 16:01, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Try this?
> <sysread.txt>
--- a/Src/input.c
+++ b/Src/input.c
(snip)
+#ifdef HAVE_FSTAT
+ else {
+ struct stat st;
+ if (fstat(SHIN, &st) == 0 && !S_ISFIFO(st.st_mode))
+ rsize = SHINBUFSIZE;
+ }
+#endif
It works for
printf '%s\n' 'echo $$' sh 'echo $$' | zsh
But in theory (yes, just in theory), SHIN can be a socket.
With two terminals A and B (zsh/socket already zmodload'ed):
A% zsocket -l /tmp/tmpsocket
A% zsocket -a $REPLY
B% zsocket /tmp/tmpsocket
A% zsh <&$REPLY
B% printf '%s\n' 'echo $$' sh 'echo $$' >&$REPLY
then on the terminal A:
zsh: lseek(0, -11): illegal seek
Adding !S_ISSOCK(st.st_mode) solves this, of course.
But at least on my Mac the following seems to work also:
if (lseek(SHIN, 0, SEEK_CUR) == 0)
rsize = SHINBUFSIZE;
# Have you found a case in which lseek(SHIN, 0, SEEK_CUR) fails
# when it shouldn't fail, or does not fail when it should fail?
If you think using fstat() is safer then I have no objection.
PS
Either fstat()/S_ISFIFO() or lseek() works when SHIN is a FIFO:
A% mkfifo fifo
A% zsh < fifo
B% printf '%s\n' 'echo $$' sh 'echo $$' > fifo
Messages sorted by:
Reverse Date,
Date,
Thread,
Author