plucky (3) ttyname_r.3.gz

Provided by: manpages-ja-dev_0.5.0.0.20221215+dfsg-1_all bug

名前

       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/ に書かれている。