TTYNAME

Section: Linux Programmer's Manual (3)
Updated: 2019-10-10
Index JM Home Page
 

名前

ttyname, ttyname_r - 端末名を返す  

書式

#include <unistd.h>

char *ttyname(int fd);

int ttyname_r(int fd, char *buf, size_t buflen);
 

説明

ttyname() 関数は、ファイルディスクリプター fd がオープンしている端末デバイスの NULL 終端されたパス名へのポインターを返す。 エラーが起きたならば NULL を返す (たとえば、fd が端末を参照していないとき)。 返り値は静的データを指しているので、次の呼び出しで上書きされる可能性がある。 ttyname_r() 関数は、このパス名を長さ buflen のバッファー buf に格納する。  

返り値

ttyname() 関数は、成功時はパス名へのポインターを返す。 エラー時は NULL を返し、 errno が適切に設定される。 ttyname_r() 関数は、成功時には 0 を返し、エラー時にはエラー番号を返す。  

エラー

EBADF
ファイルディスクリプターが不正。
ENODEV fd refers to a slave pseudoterminal device but the corresponding pathname could not be found (see NOTES).
ENOTTY
fd が端末デバイスを参照していない。
ERANGE
(ttyname_r()) buflen がパス名を格納するには短すぎる。
 

属性

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

準拠

POSIX.1-2001, POSIX.1-2008, 4.2BSD.  

注意

A process that keeps a file descriptor that refers to a pts(4) device open when switching to another mount namespace that uses a different /dev/ptmx instance may still accidentally find that a device path of the same name for that file descriptor exists. However, this device path refers to a different device and thus can't be used to access the device that the file descriptor refers to. Calling ttyname() or ttyname_r() on the file descriptor in the new mount namespace will cause these functions to return NULL and set errno to ENODEV.  

関連項目

tty(1), fstat(2), ctermid(3), isatty(3), pts(4)  

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

関連キーワード

ttyname, TTYNAME, device, エラー, 関数, file, refers, パス, descriptor, 端末

Linux マニュアル 一覧

[man1] [man2] [man3] [man4] [man5] [man6] [man7] [man8]
[a] [b] [c] [d] [e] [f] [g] [h] [i] [j] [k] [l] [m] [n] [o] [p] [q] [r] [s] [t] [u] [v] [w] [x] [y] [z]

 

Index

名前
書式
説明
返り値
エラー
属性
準拠
注意
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 12:08:37 GMT, June 11, 2022