Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: xtrace output sets ERRNO to 9 (EBADF)
- X-seq: zsh-workers 51190
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: xtrace output sets ERRNO to 9 (EBADF)
- Date: Sun, 11 Dec 2022 20:01:33 +0000
- Archived-at: <https://zsh.org/workers/51190>
- In-reply-to: <CAH+w=7ZKMq+2XGe=taPjVevkU7b34=RXr3rsV8xssLoRRRq5oA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- References: <20221209141047.oyv3jsdvo5s3z6m6@chazelas.org> <CAH+w=7bpxyzFYM-sst2D5CYWHHh5R6oggfPH5n5Pcxyq=9ShmQ@mail.gmail.com> <20221210113813.GX27622@tarpaulin.shahaf.local2> <20221211183546.ogwicuctgxbtit6w@chazelas.org> <CAH+w=7ZKMq+2XGe=taPjVevkU7b34=RXr3rsV8xssLoRRRq5oA@mail.gmail.com>
2022-12-11 10:52:44 -0800, Bart Schaefer:
[...]
> In any case,
> fileno() doesn't set errno (it's just a data structure deref, would
> only fail by crashing)
Not that it matters much here, but POSIX does say that fileno()
shall return -1 EBADF if "The stream is not associated with a
file." and may if "The file descriptor underlying stream is not
a valid file descriptor."
https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/fileno.html
musl libc has:
int fileno(FILE *f)
{
FLOCK(f);
int fd = f->fd;
FUNLOCK(f);
if (fd < 0) {
errno = EBADF;
return -1;
}
return fd;
}
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author