zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: ZSH performance regression in 5.8.1.2-test
Date: Wed, 27 Apr 2022 10:34:21 +0100 (BST)	[thread overview]
Message-ID: <632293647.60210.1651052061990@mail2.virginmedia.com> (raw)
In-Reply-To: <CAH+w=7aJVHyRXP6zjgOqQ6jmRsFNFxt_sirnod2a30kUuAwVww@mail.gmail.com>

> On 27 April 2022 at 01:38 Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Tue, Apr 26, 2022 at 7:37 AM Jun. T <takimoto-j@kba.biglobe.ne.jp> 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;
}


  reply	other threads:[~2022-04-27  9:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25 18:16 Jordan Patterson
2022-04-25 18:56 ` Bart Schaefer
2022-04-25 19:20   ` Stephane Chazelas
2022-04-25 21:27     ` Bart Schaefer
2022-04-26  7:01       ` Bart Schaefer
2022-04-26  8:31         ` Peter Stephenson
2022-04-27  0:33           ` Bart Schaefer
2022-04-27 14:11           ` Stephane Chazelas
2022-04-27 15:02             ` Bart Schaefer
2022-04-27 15:07               ` Peter Stephenson
2022-04-27 15:17                 ` Bart Schaefer
2022-04-26 14:31         ` Jun. T
2022-04-26 15:15           ` Peter Stephenson
2022-04-27  0:55             ` Bart Schaefer
2022-04-27  9:16               ` Jun T
2022-04-27  0:38           ` Bart Schaefer
2022-04-27  9:34             ` Peter Stephenson [this message]
2022-04-27 10:28               ` Jun T
2022-04-27 12:42                 ` Jun T
2022-04-27 13:58                 ` Jun T
2022-04-27 15:25                   ` Bart Schaefer
2022-04-27 16:18                     ` Jun. T
2022-04-27 19:54         ` Jordan Patterson
2022-04-28  9:53           ` Jun T
2022-04-28 14:56             ` Bart Schaefer
2022-04-28 18:51           ` Jun. T
2022-04-29  0:28             ` Bart Schaefer
2022-04-29  2:25               ` Jun. T
2022-04-26  1:08 ` Bart Schaefer
2022-04-26  3:03   ` Jordan Patterson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=632293647.60210.1651052061990@mail2.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).