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 50113
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: ZSH performance regression in 5.8.1.2-test
- Date: Wed, 27 Apr 2022 10:34:21 +0100 (BST)
- Archived-at: <https://zsh.org/workers/50113>
- Importance: Medium
- In-reply-to: <CAH+w=7aJVHyRXP6zjgOqQ6jmRsFNFxt_sirnod2a30kUuAwVww@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> <7E5CB0D9-4740-486A-B55E-6EA0530532F9@kba.biglobe.ne.jp> <CAH+w=7aJVHyRXP6zjgOqQ6jmRsFNFxt_sirnod2a30kUuAwVww@mail.gmail.com>
> On 27 April 2022 at 01:38 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Tue, Apr 26, 2022 at 7:37 AM Jun. T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
> >
> > 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?
>
> I was pretty sure I'd found a case (on Ubuntu 20.04) where it
> succeeded on a pipe when there was already data written to the pipe
> before the seek was attempted. That was only/exactly for (0,
> SEEK_CUR).
A simple test for this still caused the seek on the type to fail
here, but I could be missing the key elements. Should still
be a safe test with only a few bytes in the pipe, I would think.
pws
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h>
int main(int argc, char **argv)
{
int pipefd[2], fd;
if (pipe(pipefd) < 0)
{
printf("creating pipe failed\n");
}
else
{
char stuff[9] = "abcdefgh";
write(pipefd[1], stuff, 8);
if (lseek(pipefd[0], 0, SEEK_CUR) == (off_t)-1)
{
printf("lseek on pipe failed\n");
}
else
{
printf("lseek on pipe succeeded\n");
}
}
close(pipefd[0]);
close(pipefd[1]);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0)
{
printf("creating UNIX domain socket failed\n");
}
else if (lseek(fd, 0, SEEK_CUR) == (off_t)-1)
{
printf("lseek on UNIX domain socket failed\n");
}
else
{
printf("lseek on UNIX domain socket succeeded\n");
}
close(fd);
fd = open("seekfiletest.tmp", O_CREAT);
if (fd < 0)
{
printf("creating file failed\n");
}
else if (lseek(fd, 0, SEEK_CUR) == (off_t)-1)
{
printf("lseek on regular file failed\n");
}
else
{
printf("lseek on regular file succeeded\n");
}
close(fd);
return 0;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author