ptsname

Section: C Library Functions (3)
Updated: 2025-10-29
Index JM Home Page roff page
 

名前

ptsname, ptsname_r - スレーブ擬似端末の名前を取得する  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#include <stdlib.h>

char *ptsname(int fd);
int ptsname_r(size_t size;
              int fd, char buf[size], size_t size);

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

ptsname():


    Since glibc 2.24:
        _XOPEN_SOURCE >= 500
    glibc 2.23 and earlier:
        _XOPEN_SOURCE

ptsname_r():

    _GNU_SOURCE
 

説明

ptsname() 関数は、ファイルディスクリプター fd で参照されるマスタ擬似端末 (pts) デバイスに対応する スレーブ擬似端末デバイスの名前を返す。

The ptsname_r() function is the reentrant equivalent of ptsname(). It returns the name of the slave pseudoterminal device as a null-terminated string in the buffer pointed to by buf. The size argument specifies the number of bytes available in buf.  

返り値

成功の場合、 ptsname() は静的記憶領域の文字列へのポインターを返す。 この記憶領域はこの後の ptsname() の呼び出しで上書きされる。 このポインターを free してはいけない。 エラーの場合は NULL を返す。

成功の場合、 ptsname_r() は 0 を返す。 エラーの場合、0 以外の値を返し、エラーを示すため、エラー番号が返される。  

エラー

EINVAL
(ptsname_r() only) buf is NULL. (This error is returned only for glibc 2.25 and earlier.)
ENOTTY
fd がマスタ疑似端末デバイスを参照していない。
ERANGE
(ptsname_r() のみ) buf が小さすぎる。
 

属性

この節で使用されている用語の説明については、 attributes(7) を参照。
インターフェース属性値
ptsname() Thread safetyMT-Unsafe race:ptsname
ptsname_r() Thread safetyMT-Safe
 

バージョン

A version of ptsname_r() is documented on Tru64, HP-UX, and FreeBSD, but on those implementations, -1 is returned on error, with errno set to indicate the error. Avoid using this function in portable programs.  

標準規格

ptsname():
POSIX.1-2008.
ptsname_r():
POSIX.1-2024.
 

歴史

ptsname():
POSIX.1-2001. glibc 2.1.

ptsname() は UNIX 98 疑似端末仕様の一部である (pts(4) を参照のこと)。

ptsname_r():
GNU.
 

関連項目

grantpt(3), posix_openpt(3), ttyname(3), unlockpt(3), pts(4), pty(7)


 

Index

名前
ライブラリ
書式
説明
返り値
エラー
属性
バージョン
標準規格
歴史
関連項目

This document was created by man2html, using the manual pages.