posix_ttyname

(PHP 4, PHP 5, PHP 7, PHP 8)

posix_ttyname端末のデバイス名を調べる

説明

posix_ttyname(resource|int $file_descriptor): string|false

ファイル記述子 file_descriptor 上でオープンしている現在の端末デバイスへの絶対パスを文字列で返します。

パラメータ

fd

ファイル記述子。ファイルリソースか、あるいは int で指定します。 int を指定した場合は、システムコールにそのまま渡せるファイル記述子だとみなします。

たいていの場合は、ファイルリソースで指定することになるでしょう。

返り値

成功した場合に file_descriptor の絶対パスを表す文字列、 失敗した場合に false を返します。

add a note add a note

User Contributed Notes 1 note

up
0
casper at bcx dot nl
18 years ago
<?php
    var_dump
( posix_ttyname(STDOUT) );
?>

returns:
string(10) "/dev/pts/0"

When using pseudo terminal 1 (ie ssh)
To Top