Project

General

Profile

Actions

Bug #15294

closed

Successful read/write calls should not set errno

Added by Andy Fiddaman 5 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:
External Bug:

Description

With the changes to isatty() in #15220, a successful call to the printf(3C) functions will now set errno to 25 (ENOTTY) if the output is not a terminal.
This is inconsistent with previous behaviour, and POSIX

#include <stdio.h>
#include <errno.h>

int
main(void)
{
        errno = 123;
        (void) printf("test\n");
        printf("errno: %d\n", errno);
}
%~/isatty
test
errno: 123

% ~/isatty | cat
test
errno: 25
% dtrace -n 'pid$target::isatty:entry{ustack()}' -c ./isatty
dtrace: description 'pid$target::isatty:entry' matched 1 probe
test
errno: 123
dtrace: pid 26325 has exited
CPU     ID                    FUNCTION:NAME
  2  99403                     isatty:entry
              libc.so.1`isatty
              libc.so.1`_findbuf+0x13f
              libc.so.1`_wrtchk+0x61
              libc.so.1`puts+0x8c
              isatty`main+0x18
              isatty`_start_crt+0x87
              isatty`_start+0x18

Related issues

Related to illumos gate - Bug #15220: isatty should return reasonable errnosClosedRobert Mustacchi

Actions
Related to illumos gate - Bug #15291: zfs-tests errno flaws exposed by 15220ClosedDan McDonald

Actions
Has duplicate illumos gate - Support #15297: read does not reset errno anymoreClosed

Actions
Actions #1

Updated by Andy Fiddaman 5 months ago

  • Related to Bug #15220: isatty should return reasonable errnos added
Actions #2

Updated by Andy Fiddaman 5 months ago

  • Description updated (diff)
Actions #3

Updated by Andy Fiddaman 5 months ago

  • Description updated (diff)
Actions #4

Updated by Electric Monk 5 months ago

  • Gerrit CR set to 2582
Actions #5

Updated by Andy Fiddaman 5 months ago

Prior to this change, the newly introduced test fails:

bloody% ./printf-15294.32
test non-PTY errno value was 25, expected 0
bloody% ./printf-15294.64
test non-PTY errno value was 25, expected 0

and after, it is successful.

I also ran all of the OS and libc tests, which were successful.

Actions #6

Updated by Andy Fiddaman 5 months ago

  • Has duplicate Support #15297: read does not reset errno anymore added
Actions #7

Updated by Andy Fiddaman 5 months ago

  • Subject changed from Successful *printf() calls should not set errno to Successful read/write calls calls should not set errno
Actions #8

Updated by Andy Fiddaman 5 months ago

  • Subject changed from Successful read/write calls calls should not set errno to Successful read/write calls should not set errno
Actions #9

Updated by Dan McDonald 5 months ago

  • Related to Bug #15291: zfs-tests errno flaws exposed by 15220 added
Actions #10

Updated by Electric Monk 5 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 06ca4e396ecc93ed45a333664a51558b7e84e8f5

commit  06ca4e396ecc93ed45a333664a51558b7e84e8f5
Author: Andy Fiddaman <illumos@fiddaman.net>
Date:   2023-01-09T23:07:27.000Z

    15294 Successful read/write calls should not set errno
    Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org>
    Reviewed by: Dan Cross <cross@oxidecomputer.com>
    Approved by: Gordon Ross <gordon.w.ross@gmail.com>

Actions

Also available in: Atom PDF