Re: Why can't lseek the STDIN_FILENO?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Wen Yi <896634148(at)qq(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Why can't lseek the STDIN_FILENO?
Date: 2023-06-24 02:40:05
Message-ID: 123007.1687574405@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"=?gb18030?B?V2VuIFlp?=" <896634148(at)qq(dot)com> writes:
> &nbsp;&nbsp; &nbsp;lseek(STDIN_FILENO, 0, SEEK_SET);

If you are not checking for failure return from a system call,
you are in a state of sin.

> I really don't know, why the buffer's content not be "Hello world\n"?

Probably because a tty input device is not seekable.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John McKown 2023-06-24 03:02:06 Re: Why can't lseek the STDIN_FILENO?
Previous Message Wen Yi 2023-06-24 02:16:41 Why can't lseek the STDIN_FILENO?