標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
POSIX.1 |
両方 |
#define _POSIX_SOURCE
#include <unistd.h>
char *ctermid(char *string);
string は、ctermid() 関数が現行制御端末の名前を保管 するメモリー位置を指します。そのメモリー位置は、少なくとも L_ctermid の文字数を保持 できることが必要です。この L_ctermid は、stdio.h ヘッダー・ ファイルに定義されたシンボルです。
ctermid() は、現行プロセスの制御端末を参照するパス名として 使用できるストリングを戻します。string が NULL でない場合、ctermid() は、指定の場所にパス名 を保管し、string の値を戻します。NULL の場合には、ctermid() は、この関数固有の場所を使用して、その 場所を指すポインターを戻します。
プロセスに制御端末がある場合、戻されるパス名は、制御端末にアクセスするのに使用することができます。
ctermid() は、常に正常終了します。この関数は、現行プロセスの制御端末 を参照するパス名として使用できるストリングを戻します。
文書化される errno 値はありません。
⁄* CELEBC32
This example refers to the controlling terminal for
the current process.
*⁄
#define _POSIX_SOURCE
#include <unistd.h>
#include <stdio.h>
main() {
char termid[1025];
if (ctermid(termid) == NULL)
perror("ctermid() error");
else
printf("The control terminal is %s¥n", termid);
}
The control terminal is /dev/tty