Subject: lib/25522: ttyname_r missing
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <lha@netbsd.org>
List: netbsd-bugs
Date: 05/10/2004 13:49:18
>Number:         25522
>Category:       lib
>Synopsis:       ttyname_r missing
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 10 11:49:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Love
>Release:        NetBSD 2.0E
>Organization:
	
>Environment:
System: NetBSD nutcracker.stacken.kth.se 2.0E NetBSD 2.0E (NUTCRACKER) #81: Sun May 9 17:07:19 CEST 2004 lha@nutcracker.stacken.kth.se:/usr/src/sys/arch/i386/compile/NUTCRACKER i386
Architecture: i386
Machine: i386
>Description:
	ttyname_r missing
>How-To-Repeat:

	http://people.su.se/~lha/patches/netbsd/libc-ttyname_r

>Fix:

test app

#include <stdio.h> 
#include <fcntl.h> 
#include <unistd.h> 
#include <err.h> 

int
main(int argc, char **argv)
{
    char buf[1024];
    int fd, error;

    if ((fd = open("/dev/ttyp7", O_RDWR, 0)) < 0)
	err(1, "open");

    if ((error = ttyname_r(fd, buf, sizeof(buf))) != 0)
	errx(1, "ttyname_r: %d", error);
    
    printf("ttyname: '%s'\n", buf);
    printf("ttyname: '%s'\n", ttyname(fd));

    (void)close(fd);

    return 0;
}

>Release-Note:
>Audit-Trail:
>Unformatted: