"os" --- 雑多なオペレーティングシステムインターフェース
*******************************************************

**ソースコード:** Lib/os.py

======================================================================

このモジュールは、 OS 依存の機能を利用するポータブルな方法を提供します
。単純なファイルの読み書きについては、 "open()" を参照してください。パ
ス操作については、 "os.path" モジュールを参照してください。コマンドラ
インに与えられたすべてのファイルから行を読み込んでいくには、
"fileinput" モジュールを参照してください。一時ファイルや一時ディレクト
リの作成については、 "tempfile" モジュールを参照してください。高水準の
ファイルとディレクトリの操作については、 "shutil" モジュールを参照して
ください。

利用可能性に関する注意 :

* Python の、すべての OS 依存モジュールの設計方針は、可能な限り同一の
  インターフェースで同一の機能を利用できるようにする、というものです。
  例えば、 "os.stat(path)" は *path* に関する stat 情報を、 (POSIX を
  元にした ) 同じフォーマットで返します。

* 特定のオペレーティングシステム固有の拡張も "os" を介して利用すること
  ができますが、これらの利用はもちろん、可搬性を脅かします。

* パスやファイル名を受け付けるすべての関数は、バイト列型および文字列型
  両方のオブジェクトを受け付け、パスやファイル名を返す時は、同じ型のオ
  ブジェクトを返します。

* VxWorks では、os.popen, os.fork, os.execv および os.spawn*p* はサポ
  ートされていません。

* WebAssembly プラットフォーム、Android、iOSにおいては、"os" モジュー
  ルの大部分は利用不可能か、異なる振る舞いをします。プロセスに関連する
  API ("fork()" や "execve()" など) やリソース ("nice()" など) は利用
  不可能です。 "getuid()" や "getpid()" などの他のものは、エミュレート
  されるか、スタブです。 WebAssembly プラットフォームでは、シグナル
  ("kill()" や "wait()" など) のサポートもありません。

注釈:

  このモジュール内のすべての関数は、間違った、あるいはアクセス出来ない
  ファイル名やファイルパス、その他型が合っていても OS が受理しない引数
  に対して、 "OSError" (またはそのサブクラス)を送出します。

exception os.error

   組み込みの "OSError" 例外に対するエイリアスです。

os.name

   import されているオペレーティングシステムに依存するモジュールの名前
   です。現在次の名前が登録されています: "'posix'", "'nt'", "'java'"。

   参考:

     "sys.platform" はより細かな粒度を持っています。 "os.uname()" はシ
     ステム依存のバージョン情報を提供します。

     "platform" モジュールはシステムの詳細な識別情報をチェックする機能
     を提供しています。


ファイル名、コマンドライン引数、および環境変数
==============================================

Python では、ファイル名、コマンドライン引数、および環境変数を表すのに
文字列型を使用します。一部のシステムでは、これらをオペレーティングシス
テムに渡す前に、文字列からバイト列へ、またはその逆のデコードが必要です
。Python はこの変換を行うために *filesystem encoding and error
handler* を使用します ("sys.getfilesystemencoding()" 参照)。

term:*ファイルシステムのエンコーディングとエラーハンドラ <filesystem
encoding and error handler>* は、Pythonの開始時に
:c:func:*PyConfig_Read* 関数により設定されます。 "PyConfig" のメンバー
"filesystem_encoding" と "filesystem_errors" を参照してください。

バージョン 3.1 で変更: 一部のシステムでは、ファイルシステムのエンコー
ディングを使用して変換すると失敗する場合があります。この場合、Python
は  surrogateescape エンコーディングエラーハンドラー を使用します。こ
れは、デコード時にデコードできないバイト列は Unicode 文字 U+DC*xx* に
置き換えられ、それらはエンコード時に再び元のバイト列に変換されることを
意味します。

*file system encoding* では、すべてが 128 バイト以下に正常にデコードさ
れることが保証されなくてはなりません。ファイルシステムのエンコーディン
グでこれが保証されなかった場合は、API 関数が "UnicodeError" を送出しま
す。

See also the *locale encoding*.


Python UTF-8 Mode
=================

Added in version 3.7: より詳しくは **PEP 540** を参照してください。

The Python UTF-8 Mode ignores the *locale encoding* and forces the
usage of the UTF-8 encoding:

* Use UTF-8 as the *filesystem encoding*.

* "sys.getfilesystemencoding()" returns "'utf-8'".

* "locale.getpreferredencoding()" returns "'utf-8'" (the
  *do_setlocale* argument has no effect).

* "sys.stdin", "sys.stdout", and "sys.stderr" all use UTF-8 as their
  text encoding, with the "surrogateescape" error handler being
  enabled for "sys.stdin" and "sys.stdout" ("sys.stderr" continues to
  use "backslashreplace" as it does in the default locale-aware mode)

* On Unix, "os.device_encoding()" returns "'utf-8'" rather than the
  device encoding.

Note that the standard stream settings in UTF-8 mode can be overridden
by "PYTHONIOENCODING" (just as they can be in the default locale-aware
mode).

As a consequence of the changes in those lower level APIs, other
higher level APIs also exhibit different default behaviours:

* Command line arguments, environment variables and filenames are
  decoded to text using the UTF-8 encoding.

* "os.fsdecode()" and "os.fsencode()" use the UTF-8 encoding.

* "open()", "io.open()", and "codecs.open()" use the UTF-8 encoding by
  default. However, they still use the strict error handler by default
  so that attempting to open a binary file in text mode is likely to
  raise an exception rather than producing nonsense data.

The Python UTF-8 Mode is enabled if the LC_CTYPE locale is "C" or
"POSIX" at Python startup (see the "PyConfig_Read()" function).

It can be enabled or disabled using the "-X utf8" command line option
and the "PYTHONUTF8" environment variable.

If the "PYTHONUTF8" environment variable is not set at all, then the
interpreter defaults to using the current locale settings, *unless*
the current locale is identified as a legacy ASCII-based locale (as
described for "PYTHONCOERCECLOCALE"), and locale coercion is either
disabled or fails. In such legacy locales, the interpreter will
default to enabling UTF-8 mode unless explicitly instructed not to do
so.

The Python UTF-8 Mode can only be enabled at the Python startup. Its
value can be read from "sys.flags.utf8_mode".

See also the UTF-8 mode on Windows and the *filesystem encoding and
error handler*.

参考:

  **PEP 686**
     Python 3.15 will make Python UTF-8 Mode default.


プロセスのパラメーター
======================

これらの関数とデータアイテムは、現在のプロセスおよびユーザーに対する情
報提供および操作のための機能を提供しています。

os.ctermid()

   プロセスの制御端末に対応するファイル名を返します。

   Availability: Unix, not WASI.

os.environ

   A *mapping* object where keys and values are strings that represent
   the process environment.  For example, "environ['HOME']" is the
   pathname of your home directory (on some platforms), and is
   equivalent to "getenv("HOME")" in C.

   このマップ型の内容は、 "os" モジュールの最初の import の時点、通常
   は Python の起動時に "site.py" が処理される中で取り込まれます。それ
   以後に変更された環境変数は "os.environ" を直接変更しない限り
   "os.environ" には反映されません。

   このマップ型オブジェクトは環境変数に対する変更に使うこともできます
   。 "putenv()" はマップ型オブジェクトが修正される時に、自動的に呼ば
   れることになります。

   Unix では、キーと値に "sys.getfilesystemencoding()"、エラーハンドラ
   ーに "'surrogateescape'" を使用します。異なるエンコーディングを使用
   したい場合は "environb" を使用します。

   On Windows, the keys are converted to uppercase. This also applies
   when getting, setting, or deleting an item. For example,
   "environ['monty'] = 'python'" maps the key "'MONTY'" to the value
   "'python'".

   注釈:

     "putenv()" を直接呼び出しても "os.environ" の内容は変わらないので
     、 "os.environ" を直接変更する方が良いです。

   注釈:

     FreeBSD や macOS など一部のプラットフォームでは "environ" の値を
     変更するとメモリリークが発生する可能性があります。各システムのド
     キュメントで "putenv()" の項目を参照してください。

   このマップ型オブジェクトからアイテムを削除することで環境変数を消す
   ことができます。 "unsetenv()" は "os.environ" からアイテムが取り除
   かれた時に自動的に呼ばれます。 "pop()" または "clear()" が呼ばれた
   時も同様です。

   参考: The "os.reload_environ()" function.

   バージョン 3.9 で変更: 更新され **PEP 584** の合成演算子 ("|") と更
   新演算子 ("|=") がサポートされました。

os.environb

   Bytes version of "environ": a *mapping* object where both keys and
   values are "bytes" objects representing the process environment.
   "environ" and "environb" are synchronized (modifying "environb"
   updates "environ", and vice versa).

   "environb" は "supports_bytes_environ" が "True" の場合のみ利用可能
   です。

   Added in version 3.2.

   バージョン 3.9 で変更: 更新され **PEP 584** の合成演算子 ("|") と更
   新演算子 ("|=") がサポートされました。

os.reload_environ()

   The "os.environ" and "os.environb" mappings are a cache of
   environment variables at the time that Python started. As such,
   changes to the current process environment are not reflected if
   made outside Python, or by "os.putenv()" or "os.unsetenv()". Use
   "os.reload_environ()" to update "os.environ" and "os.environb" with
   any such changes to the current process environment.

   警告:

     This function is not thread-safe. Calling it while the
     environment is being modified in an other thread is an undefined
     behavior. Reading from "os.environ" or "os.environb", or calling
     "os.getenv()" while reloading, may return an empty result.

   Added in version 3.14.

os.chdir(path)
os.fchdir(fd)
os.getcwd()

   これらの関数は、 ファイルとディレクトリ 節で説明されています。

os.fsencode(filename)

   *path-like* な *filename* を *ファイルシステムのエンコーディングと
   エラーハンドラ* にエンコードします。未変更の "bytes" オブジェクトを
   返します。

   "fsdecode()" はこの逆変換を行う関数です。

   Added in version 3.2.

   バージョン 3.6 で変更: "os.PathLike" インターフェースを実装したオブ
   ジェクトを受け入れるようになりました。

os.fsdecode(filename)

   *path-like* な *filename* を *ファイルシステムのエンコーディングと
   エラーハンドラ* からデコードします。未変更の "str" オブジェクトを返
   します。

   "fsencode()" はこの逆変換を行う関数です。

   Added in version 3.2.

   バージョン 3.6 で変更: "os.PathLike" インターフェースを実装したオブ
   ジェクトを受け入れるようになりました。

os.fspath(path)

   path のファイルシステム表現を返します。

   もし "str" か "bytes:" のオブジェクトが渡された場合は、変更せずにそ
   のまま返します。さもなければ、 "__fspath__()" が呼び出され、その戻
   り値が "str" か "bytes" のオブジェクトであれば、その値を返します。
   他のすべてのケースでは "TypeError" が送出されます。

   Added in version 3.6.

class os.PathLike

   ファイルシステムパスを表すオブジェクト(例: "pathlib.PurePath") 向け
   の *abstract base class* です。

   Added in version 3.6.

   abstractmethod __fspath__()

      このオブジェクトが表現するファイルシステムパスを返します。

      このメソッドは "str" か "bytes" のオブジェクトのみを返す必要があ
      ります("str" が好まれます)。

os.getenv(key, default=None)

   環境変数 *key* が存在する場合はその値を文字列として返し、存在しなけ
   れば *default* を返します。*key* は文字列です。注意すべき点として、
   "getenv()" は内部的に "os.environ" を使用するため、"getenv()" のマ
   ップ型オブジェクトはインポート時に取得されます。そのため、それ以降
   に環境変数が変更されても、この関数の値にそれが反映されない可能性が
   あります。

   Unix では、キーと値は "sys.getfilesystemencoding()"、エラーハンドラ
   ー "'surrogateescape'" でデコードされます。異なるエンコーディングを
   使用したい場合は "os.getenvb()" を使用します。

   Availability: Unix, Windows.

os.getenvb(key, default=None)

   環境変数 *key* が存在する場合はその値を bytes として返し、存在しな
   ければ *default* を返します。*key* はbytes である必要があります。注
   意すべき点として、"getenvb()" は内部的に "os.environb" を使用するた
   め、"getenvb()" のマップ型オブジェクトはインポート時に取得されます
   。そのため、それ以降に環境変数が変更されても、この関数の値にそれが
   反映されない可能性があります。

   "getenvb()" は "supports_bytes_environ" が "True" の場合のみ利用可
   能です。

   Availability: Unix.

   Added in version 3.2.

os.get_exec_path(env=None)

   プロセスを起動する時に名前付き実行ファイルを検索するディレクトリの
   リストを返します。 *env* が指定されると、それを環境変数の辞書とみな
   し、その辞書からキー PATH の値を探します。 デフォルトでは *env* は
   "None" であり、"environ" が使用されます。

   Added in version 3.2.

os.getegid()

   現在のプロセスの実効グループ id を返します。この id は現在のプロセ
   スで実行されているファイルの "set id" ビットに対応します。

   Availability: Unix, not WASI.

os.geteuid()

   現在のプロセスの実効ユーザー id を返します。

   Availability: Unix, not WASI.

os.getgid()

   現在のプロセスの実グループ id を返します。

   Availability: Unix.

   The function is a stub on WASI, see WebAssembly プラットフォーム
   for more information.

os.getgrouplist(user, group, /)

   Return list of group ids that *user* belongs to. If *group* is not
   in the list, it is included; typically, *group* is specified as the
   group ID field from the password record for *user*, because that
   group ID will otherwise be potentially omitted.

   Availability: Unix, not WASI.

   Added in version 3.3.

os.getgroups()

   現在のプロセスに関連付けられた従属グループ id のリストを返します。

   Availability: Unix, not WASI.

   注釈:

     macOS では "getgroups()" の挙動は他の Unix プラットフォームとはい
     くぶん異なります。 Python のインタープリタが "10.5" 以前の
     Deployment Target でビルドされている場合、 "getgroups()" は現在の
     ユーザープロセスに関連付けられている実効グループ id を返します。
     このリストはシステムで定義されたエントリ数 ( 通常は 16) に制限さ
     れ、適切な特権があれば "setgroups()" の呼び出しによって変更するこ
     とができます。 "10.5" より新しい Deployment Target でビルドされて
     いる場合、 "getgroups()" はプロセスの実効ユーザー id に関連付けら
     れたユーザーの現在のグループアクセスリストを返します。このグルー
     プアクセスリストは、プロセスのライフタイムで変更される可能性があ
     り、 "setgroups()" の呼び出しの影響を受けず、長さ 16 の制限を受け
     ません。 Deployment Target の値 "MACOSX_DEPLOYMENT_TARGET" は、
     "sysconfig.get_config_var()" で取得することができます。

os.getlogin()

   プロセスの制御端末にログインしているユーザー名を返します。ほとんど
   の場合、"getpass.getuser()" を使う方が便利です。なぜなら、
   "getpass.getuser()" は、ユーザーを見つけるために、環境変数
   "LOGNAME" や "USERNAME" を調べ、さらには
   "pwd.getpwuid(os.getuid())[0]" まで調べに行くからです。

   Availability: Unix, Windows, not WASI.

os.getpgid(pid)

   プロセス id *pid* のプロセスのプロセスグループ id を返します。
   *pid* が 0 の場合、現在のプロセスのプロセスグループ id を返します。

   Availability: Unix, not WASI.

os.getpgrp()

   現在のプロセスグループの id を返します。

   Availability: Unix, not WASI.

os.getpid()

   現在のプロセス id を返します。

   The function is a stub on WASI, see WebAssembly プラットフォーム
   for more information.

os.getppid()

   親プロセスのプロセス id を返します。親プロセスが終了していた場合、
   Unix では init プロセスの id (1) が返され、Windows では親のプロセス
   id だったもの (別のプロセスで再利用されているかもしれない) がそのま
   ま返されます。

   Availability: Unix, Windows, not WASI.

   バージョン 3.2 で変更: Windows サポートが追加されました。

os.getpriority(which, who)

   プログラムのスケジューリング優先度を取得します。*which* の値は
   "PRIO_PROCESS"、"PRIO_PGRP"、あるいは "PRIO_USER" のいずれか一つで
   、*who* の値は *which* に応じて解釈されます ("PRIO_PROCESS" であれ
   ばプロセス識別子、"PRIO_PGRP" であればプロセスグループ識別子、そし
   て "PRIO_USER" であればユーザー ID)。*who* の値がゼロの場合、呼び出
   したプロセス、呼び出したプロセスのプロセスグループ、および呼び出し
   たプロセスの実ユーザー id を (それぞれ) 意味します。

   Availability: Unix, not WASI.

   Added in version 3.3.

os.PRIO_PROCESS
os.PRIO_PGRP
os.PRIO_USER

   "getpriority()" と "setpriority()" 用のパラメータです。

   Availability: Unix, not WASI.

   Added in version 3.3.

os.PRIO_DARWIN_THREAD
os.PRIO_DARWIN_PROCESS
os.PRIO_DARWIN_BG
os.PRIO_DARWIN_NONUI

   "getpriority()" と "setpriority()" 用のパラメータです。

   Availability: macOS

   Added in version 3.12.

os.getresuid()

   現在のプロセスの実ユーザー id 、実効ユーザー id 、および保存ユーザ
   ー id を示す、 (ruid, euid, suid) のタプルを返します。

   Availability: Unix, not WASI.

   Added in version 3.2.

os.getresgid()

   現在のプロセスの実グループ id 、実効グループ id 、および保存グルー
   プ id を示す、 (rgid, egid, sgid) のタプルを返します。

   Availability: Unix, not WASI.

   Added in version 3.2.

os.getuid()

   現在のプロセスの実ユーザー id を返します。

   Availability: Unix.

   The function is a stub on WASI, see WebAssembly プラットフォーム
   for more information.

os.initgroups(username, gid, /)

   Call the system "initgroups()" to initialize the group access list
   with all of the groups of which the specified username is a member,
   plus the specified group id.

   Availability: Unix, not WASI, not Android.

   Added in version 3.2.

os.putenv(key, value, /)

   *key* という名前の環境変数に文字列 *value* を設定します。このような
   環境変数の変更は、"os.system()"、"popen()"、または "fork()" と
   "execv()" で起動されたサブプロセスに影響を与えます。

   "os.environ" の要素に代入すると、それは "putenv()" の呼び出しに自動
   変換されます。 しかし、直接 "putenv()" を呼び出しても "os.environ"
   には反映されないため、"os.environ" の要素に代入する方がベターです。
   "getenv()" と "getenvb()" についても、実装上それぞれ "os.environ"
   と "os.environb" を使用するので、同様に注意が必要です。

   See also the "os.reload_environ()" function.

   注釈:

     FreeBSD や macOS など一部のプラットフォームでは "environ" の値を
     変更するとメモリリークが発生する可能性があります。 各システムのド
     キュメントで "putenv()" の項目を参照してください。

   引数 "key", "value" を指定して 監査イベント "os.putenv" を送出しま
   す。

   バージョン 3.9 で変更: 常に利用出来るようになりました。

os.setegid(egid, /)

   現在のプロセスに実効グループ id をセットします。

   Availability: Unix, not WASI, not Android.

os.seteuid(euid, /)

   現在のプロセスに実効ユーザー id をセットします。

   Availability: Unix, not WASI, not Android.

os.setgid(gid, /)

   現在のプロセスにグループ id をセットします。

   Availability: Unix, not WASI, not Android.

os.setgroups(groups, /)

   現在のグループに関連付けられた従属グループ id のリストを *groups*
   に設定します。 *groups* はシーケンス型でなくてはならず、各要素はグ
   ループを特定する整数でなくてはなりません。通常、この操作はスーパユ
   ーザーしか利用できません。

   Availability: Unix, not WASI.

   注釈:

     macOS では、 *groups* の長さはシステムで定義された実効グループ id
     の最大数 ( 通常は 16) を超えない場合があります。 setgroups() 呼び
     出しで設定されたものと同じグループリストが返されないケースについ
     ては、 "getgroups()" のドキュメントを参照してください。

os.setns(fd, nstype=0)

   Reassociate the current thread with a Linux namespace. See the
   *setns(2)* and *namespaces(7)* man pages for more details.

   If *fd* refers to a "/proc/*pid*/ns/" link, "setns()" reassociates
   the calling thread with the namespace associated with that link,
   and *nstype* may be set to one of the CLONE_NEW* constants to
   impose constraints on the operation ("0" means no constraints).

   Since Linux 5.8, *fd* may refer to a PID file descriptor obtained
   from "pidfd_open()". In this case, "setns()" reassociates the
   calling thread into one or more of the same namespaces as the
   thread referred to by *fd*. This is subject to any constraints
   imposed by *nstype*, which is a bit mask combining one or more of
   the CLONE_NEW* constants, e.g. "setns(fd, os.CLONE_NEWUTS |
   os.CLONE_NEWPID)". The caller's memberships in unspecified
   namespaces are left unchanged.

   *fd* can be any object with a "fileno()" method, or a raw file
   descriptor.

   This example reassociates the thread with the "init" process's
   network namespace:

      fd = os.open("/proc/1/ns/net", os.O_RDONLY)
      os.setns(fd, os.CLONE_NEWNET)
      os.close(fd)

   Availability: Linux >= 3.0 with glibc >= 2.14.

   Added in version 3.12.

   参考: The "unshare()" function.

os.setpgrp()

   システムコール "setpgrp()" か "setpgrp(0, 0)" のどちらか(実装されて
   いるもの)を呼び出します。機能については UNIX マニュアルを参照して下
   さい。

   Availability: Unix, not WASI.

os.setpgid(pid, pgrp, /)

   システムコール "setpgid()" を呼び出してプロセス id *pid* のプロセス
   のプロセスグループ id を *pgrp* に設定します。この動作に関しては
   Unix のマニュアルを参照してください。

   Availability: Unix, not WASI.

os.setpriority(which, who, priority)

   プログラムのスケジューリング優先度を設定します。*which* は
   "PRIO_PROCESS"、"PRIO_PGRP"、あるいは "PRIO_USER" のいずれか一つで
   、*who* の値は *which* に応じて解釈されます ("PRIO_PROCESS" であれ
   ばプロセス識別子、"PRIO_PGRP" であればプロセスグループ識別子、そし
   て "PRIO_USER" であればユーザー ID)。*who* の値がゼロの場合、呼び出
   したプロセス、呼び出したプロセスのプロセスグループ、および呼び出し
   たプロセスの実ユーザー id を (それぞれ) 意味します。*priority* は
   -20 から 19 の整数値で、デフォルトの優先度は 0 です。小さい数値ほど
   優先されるスケジューリングとなります。

   Availability: Unix, not WASI.

   Added in version 3.3.

os.setregid(rgid, egid, /)

   現在のプロセスの実グループ id および実効グループ id を設定します。

   Availability: Unix, not WASI, not Android.

os.setresgid(rgid, egid, sgid, /)

   現在のプロセスの、実グループ id 、実効グループ id 、および保存グル
   ープ id を設定します。

   Availability: Unix, not WASI, not Android.

   Added in version 3.2.

os.setresuid(ruid, euid, suid, /)

   現在のプロセスの実ユーザー id 、実効ユーザー id 、および保存ユーザ
   ー id を設定します。

   Availability: Unix, not WASI, not Android.

   Added in version 3.2.

os.setreuid(ruid, euid, /)

   現在のプロセスの実ユーザー id および実効ユーザー id を設定します。

   Availability: Unix, not WASI, not Android.

os.getsid(pid, /)

   "getsid()" システムコールを呼び出します。機能については Unix のマニ
   ュアルを参照してください。

   Availability: Unix, not WASI.

os.setsid()

   "setsid()" システムコールを呼び出します。機能については Unix のマニ
   ュアルを参照してください。

   Availability: Unix, not WASI.

os.setuid(uid, /)

   現在のプロセスのユーザー id を設定します。

   Availability: Unix, not WASI, not Android.

os.strerror(code, /)

   エラーコード *code* に対応するエラーメッセージを返します。未知のエ
   ラーコードの対して "strerror()" が "NULL" を返すプラットフォームで
   は、 "ValueError" が送出されます。

os.supports_bytes_environ

   環境のネイティブ OS タイプがバイト型の場合、 "True" です (例:
   Windows では、 "False" です)。

   Added in version 3.2.

os.umask(mask, /)

   現在の数値 umask を設定し、以前の umask 値を返します。

   The function is a stub on WASI, see WebAssembly プラットフォーム
   for more information.

os.uname()

   現在のオペレーティングシステムを識別する情報を返します。返り値は 5
   個の属性を持つオブジェクトです:

   * "sysname" - OS の名前

   * "nodename" - (実装時に定義された) ネットワーク上でのマシン名

   * "release" - OS のリリース

   * "version" - OS のバージョン

   * "machine" - ハードウェア識別子

   後方互換性のため、このオブジェクトはイテラブルでもあり、"sysname"、
   "nodename"、"release"、"version"、および "machine" の 5 個の要素を
   この順序で持つタプルのように振る舞います。

   一部のシステムでは、"nodename" はコンポーネントを読み込むために 8
   文字または先頭の要素だけに切り詰められます; ホスト名を取得する方法
   としては、"socket.gethostname()" を使う方がよいでしょう。あるいは
   "socket.gethostbyaddr(socket.gethostname())" でもかまいません。

   On macOS, iOS and Android, this returns the *kernel* name and
   version (i.e., "'Darwin'" on macOS and iOS; "'Linux'" on Android).
   "platform.uname()" can be used to get the user-facing operating
   system name and version on iOS and Android.

   Availability: Unix.

   バージョン 3.3 で変更: 返り値の型が、タプルから属性名のついたタプル
   ライクオブジェクトに変更されました。

os.unsetenv(key, /)

   *key* という名前の環境変数を unset (削除) します。このような環境変
   数の変更は、"os.system()"、"popen()"、または "fork()" と "execv()"
   で起動されたサブプロセスに影響を与えます。

   "os.environ" のアイテムの削除を行うと、自動的に "unsetenv()" の対応
   する呼び出しに変換されます。直接 "unsetenv()" を呼び出した場合
   "os.environ" は更新されないため、実際には "os.environ" のアイテムを
   削除する方が望ましい操作です。

   See also the "os.reload_environ()" function.

   引数 "key" を指定して 監査イベント "os.unsetenv" を送出します。

   バージョン 3.9 で変更: 常に関数は利用出来るようになりました。

os.unshare(flags)

   Disassociate parts of the process execution context, and move them
   into a newly created namespace. See the *unshare(2)* man page for
   more details. The *flags* argument is a bit mask, combining zero or
   more of the CLONE_* constants, that specifies which parts of the
   execution context should be unshared from their existing
   associations and moved to a new namespace. If the *flags* argument
   is "0", no changes are made to the calling process's execution
   context.

   Availability: Linux >= 2.6.16.

   Added in version 3.12.

   参考: "setns()" 関数。

Flags to the "unshare()" function, if the implementation supports
them. See *unshare(2)* in the Linux manual for their exact effect and
availability.

os.CLONE_FILES
os.CLONE_FS
os.CLONE_NEWCGROUP
os.CLONE_NEWIPC
os.CLONE_NEWNET
os.CLONE_NEWNS
os.CLONE_NEWPID
os.CLONE_NEWTIME
os.CLONE_NEWUSER
os.CLONE_NEWUTS
os.CLONE_SIGHAND
os.CLONE_SYSVSEM
os.CLONE_THREAD
os.CLONE_VM


ファイルオブジェクトの生成
==========================

以下の関数は新しい *ファイルオブジェクト* を作成します。(ファイル記述
子のオープンについては "open()" も参照してください)

os.fdopen(fd, *args, **kwargs)

   ファイル記述子 *fd* に接続し、オープンしたファイルオブジェクトを返
   します。これは組み込み関数 "open()" の別名であり、同じ引数を受け取
   ります。唯一の違いは "fdopen()" の第一引数が常に整数でなければなら
   ないことです。


ファイル記述子の操作
====================

これらの関数は、ファイル記述子を使って参照されている I/O ストリームを
操作します。

ファイル記述子とは現在のプロセスで開かれたファイルに対応する小さな整数
です。例えば、標準入力のファイル記述子は通常 0 で、標準出力は 1 、標準
エラーは 2 です。プロセスから開かれたその他のファイルには 3 、 4 、 5
と割り振られていきます。「ファイル記述子」という名称は少し誤解を与える
ものかもしれません。Unix プラットフォームでは、ソケットやパイプもファ
イル記述子によって参照されます。

"fileno()" メソッドを使用して、必要な場合に *file object* に関連付けら
れているファイル記述子を取得することができます。ファイル記述子を直接使
用すると、ファイルオブジェクトのメソッドが使用されないため、データの内
部バッファなどの性質は無視されることに注意してください。

os.close(fd)

   ファイル記述子 *fd* をクローズします。

   注釈:

     この関数は低水準の I/O 向けのもので、 "os.open()" や "pipe()" が
     返すファイル記述子に対して使用しなければなりません。 組み込み関数
     "open()" や "popen()" 、 "fdopen()" が返す "ファイルオブジェクト"
     を閉じるには、オブジェクトの "close()" メソッドを使用してください
     。

os.closerange(fd_low, fd_high, /)

   *fd_low* 以上 *fd_high* 未満のすべてのファイル記述子をエラーを無視
   してクローズします。以下のコードと等価です:

      for fd in range(fd_low, fd_high):
          try:
              os.close(fd)
          except OSError:
              pass

os.copy_file_range(src, dst, count, offset_src=None, offset_dst=None)

   Copy *count* bytes from file descriptor *src*, starting from offset
   *offset_src*, to file descriptor *dst*, starting from offset
   *offset_dst*. If *offset_src* is "None", then *src* is read from
   the current position; respectively for *offset_dst*.

   In Linux kernel older than 5.3, the files pointed to by *src* and
   *dst* must reside in the same filesystem, otherwise an "OSError" is
   raised with "errno" set to "errno.EXDEV".

   This copy is done without the additional cost of transferring data
   from the kernel to user space and then back into the kernel.
   Additionally, some filesystems could implement extra optimizations,
   such as the use of reflinks (i.e., two or more inodes that share
   pointers to the same copy-on-write disk blocks; supported file
   systems include btrfs and XFS) and server-side copy (in the case of
   NFS).

   The function copies bytes between two file descriptors. Text
   options, like the encoding and the line ending, are ignored.

   返り値はコピーされたバイトの量です。 この値は、要求した量より少なく
   なることもあります。

   注釈:

     On Linux, "os.copy_file_range()" should not be used for copying a
     range of a pseudo file from a special filesystem like procfs and
     sysfs. It will always copy no bytes and return 0 as if the file
     was empty because of a known Linux kernel issue.

   Availability: Linux >= 4.5 with glibc >= 2.27.

   Added in version 3.8.

os.device_encoding(fd)

   *fd* に関連付けられたデバイスが端末 (ターミナル) に接続されている場
   合に、そのデバイスのエンコーディングを表す文字列を返します。端末に
   接続されていない場合、 "None" を返します。

   On Unix, if the Python UTF-8 Mode is enabled, return "'UTF-8'"
   rather than the device encoding.

   バージョン 3.10 で変更: On Unix, the function now implements the
   Python UTF-8 Mode.

os.dup(fd, /)

   ファイル記述子 *fd* の複製を返します。新しいファイル記述子は 継承不
   可 です。

   Windows では、標準ストリーム (0: 標準入力、1: 標準出力、2: 標準エラ
   ー出力) を複製する場合、新しいファイル記述子は 継承可能 です。

   Availability: not WASI.

   バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

os.dup2(fd, fd2, inheritable=True)

   ファイル記述子 *fd* を *fd2* に複製し、必要な場合には後者を先に閉じ
   ます。 *fd2* が返ります。 新しいファイル記述子はデフォルトでは 継承
   可能 で、*inheritable* が "False" の場合は継承不可です。

   Availability: not WASI.

   バージョン 3.4 で変更: オプションの *inheritable* 引数が追加されま
   した。

   バージョン 3.7 で変更: 成功したときは *fd2* が返ります。 以前は常に
   "None" が返っていました。

os.fchmod(fd, mode)

   *fd* で指定されたファイルのモードを *mode* に変更します。*mode* に
   指定できる値については、"chmod()" のドキュメントを参照してください
   。Python 3.3 以降では "os.chmod(fd, mode)" と等価です。

   引数 "path", "mode", "dir_fd" を指定して 監査イベント "os.chmod" を
   送出します。

   Availability: Unix, Windows.

   The function is limited on WASI, see WebAssembly プラットフォーム
   for more information.

   バージョン 3.13 で変更: Added support on Windows.

os.fchown(fd, uid, gid)

   *fd* で指定されたファイルの所有者 id およびグループ id を数値 *uid*
   および *gid* に変更します。いずれかの id を変更せずにおくにはその値
   として -1 を指定します。"chown()" を参照してください。Python 3.3 以
   降では "os.chown(fd, uid, gid)" と等価です。

   引数 "path", "uid", "gid", "dir_fd" を指定して 監査イベント
   "os.chown" を送出します。

   Availability: Unix.

   The function is limited on WASI, see WebAssembly プラットフォーム
   for more information.

os.fdatasync(fd)

   ファイル記述子 *fd* を持つファイルのディスクへの書き込みを強制しま
   す。メタデータの更新は強制しません。

   Availability: Unix.

   注釈:

     この関数は MacOS では利用できません。

os.fpathconf(fd, name, /)

   開いているファイルに関連するシステム設定情報を返します。 *name* は
   取得する設定名を指定します。これは、いくつかの標準 (POSIX.1 、 Unix
   95 、 Unix 98 その他 ) で定義された定義済みのシステム値名の文字列で
   ある場合があります。プラットフォームによっては別の名前も定義されて
   います。ホストオペレーティングシステムの関知する名前は
   "pathconf_names" 辞書で与えられています。このマップ型オブジェクトに
   含まれていない構成変数については、 *name* に整数を渡してもかまいま
   せん。

   *name* が不明の文字列である場合、 "ValueError" を送出します。
   *name* の特定の値がホストシステムでサポートされていない場合、
   "pathconf_names" に含まれていたとしても、 "errno.EINVAL" をエラー番
   号として "OSError" を送出します。

   Python 3.3 以降では "os.pathconf(fd, name)" と等価です。

   Availability: Unix.

os.fstat(fd)

   ファイル記述子 *fd* の状態を取得します。"stat_result" オブジェクト
   を返します。

   Python 3.3 以降では "os.stat(fd)" と等価です。

   参考: "stat()" 関数。

os.fstatvfs(fd, /)

   "statvfs()" と同様に、ファイル記述子 *fd* に関連付けられたファイル
   が格納されているファイルシステムに関する情報を返します。Python 3.3
   以降では "os.statvfs(fd)" と等価です。

   Availability: Unix.

os.fsync(fd)

   ファイル記述子 *fd* を持つファイルのディスクへの書き込みを強制しま
   す。 Unix では、ネイティブの "fsync()" 関数を、 Windows では
   "_commit()" 関数を呼び出します。

   Python の *ファイルオブジェクト* *f* を使う場合、*f* の内部バッファ
   を確実にディスクに書き込むために、まず "f.flush()" を、その後
   "os.fsync(f.fileno())" を実行してください。

   Availability: Unix, Windows.

os.ftruncate(fd, length, /)

   ファイル記述子 *fd* に対応するファイルを、サイズが最長で *length*
   バイトになるように切り詰めます。Python 3.3 以降では
   "os.truncate(fd, length)" と等価です。

   引数 "fd", "length" を指定して 監査イベント "os.truncate" を送出し
   ます。

   Availability: Unix, Windows.

   バージョン 3.5 で変更: Windows サポートを追加しました。

os.get_blocking(fd, /)

   記述子のブロッキングモードを取得します。 "O_NONBLOCK" フラグが設定
   されている場合は "False" で、フラグがクリアされている場合は "True"
   です。

   "set_blocking()" および "socket.socket.setblocking()" も参照してく
   ださい。

   Availability: Unix, Windows.

   The function is limited on WASI, see WebAssembly プラットフォーム
   for more information.

   On Windows, this function is limited to pipes.

   Added in version 3.5.

   バージョン 3.12 で変更: Added support for pipes on Windows.

os.grantpt(fd, /)

   Grant access to the slave pseudo-terminal device associated with
   the master pseudo-terminal device to which the file descriptor *fd*
   refers. The file descriptor *fd* is not closed upon failure.

   Calls the C standard library function "grantpt()".

   Availability: Unix, not WASI.

   Added in version 3.13.

os.isatty(fd, /)

   ファイル記述子 *fd* がオープンされていて、 tty (のような) デバイス
   に接続されている場合、 "True" を返します。そうでない場合は "False"
   を返します。

os.lockf(fd, cmd, len, /)

   オープンされたファイル記述子に対して、POSIX ロックの適用、テスト、
   解除を行います。*fd* はオープンされたファイル記述子です。*cmd* には
   使用するコマンド ("F_LOCK"、"F_TLOCK"、"F_ULOCK"、あるいは "F_TEST"
   のいずれか一つ) を指定します。*len* にはロックするファイルのセクシ
   ョンを指定します。

   引数 "fd", "cmd", "len" を指定して 監査イベント "os.lockf" を送出し
   ます。

   Availability: Unix.

   Added in version 3.3.

os.F_LOCK
os.F_TLOCK
os.F_ULOCK
os.F_TEST

   "lockf()" がとる動作を指定するフラグです。

   Availability: Unix.

   Added in version 3.3.

os.login_tty(fd, /)

   Prepare the tty of which fd is a file descriptor for a new login
   session. Make the calling process a session leader; make the tty
   the controlling tty, the stdin, the stdout, and the stderr of the
   calling process; close fd.

   Availability: Unix, not WASI.

   Added in version 3.11.

os.lseek(fd, pos, whence, /)

   Set the current position of file descriptor *fd* to position *pos*,
   modified by *whence*, and return the new position in bytes relative
   to the start of the file. Valid values for *whence* are:

   * "SEEK_SET" or "0" -- set *pos* relative to the beginning of the
     file

   * "SEEK_CUR" or "1" -- set *pos* relative to the current file
     position

   * "SEEK_END" or "2" -- set *pos* relative to the end of the file

   * "SEEK_HOLE" -- set *pos* to the next data location, relative to
     *pos*

   * "SEEK_DATA" -- set *pos* to the next data hole, relative to *pos*

   バージョン 3.3 で変更: Add support for "SEEK_HOLE" and "SEEK_DATA".

os.SEEK_SET
os.SEEK_CUR
os.SEEK_END

   Parameters to the "lseek()" function and the "seek()" method on
   *file-like objects*, for whence to adjust the file position
   indicator.

   "SEEK_SET"
      Adjust the file position relative to the beginning of the file.

   "SEEK_CUR"
      Adjust the file position relative to the current file position.

   "SEEK_END"
      Adjust the file position relative to the end of the file.

   Their values are 0, 1, and 2, respectively.

os.SEEK_HOLE
os.SEEK_DATA

   Parameters to the "lseek()" function and the "seek()" method on
   *file-like objects*, for seeking file data and holes on sparsely
   allocated files.

   "SEEK_DATA"
      Adjust the file offset to the next location containing data,
      relative to the seek position.

   "SEEK_HOLE"
      Adjust the file offset to the next location containing a hole,
      relative to the seek position. A hole is defined as a sequence
      of zeros.

   注釈:

     These operations only make sense for filesystems that support
     them.

   Availability: Linux >= 3.1, macOS, Unix

   Added in version 3.3.

os.open(path, flags, mode=0o777, *, dir_fd=None)

   ファイル *path* を開き、*flag* に従って様々なフラグを設定し、可能な
   ら *mode* に従ってファイルモードを設定します。*mode* を計算する際、
   まず現在の umask 値でマスクされます。新たに開いたファイルのファイル
   記述子を返します。新しいファイル記述子は 継承不可 です。

   フラグとファイルモードの値についての詳細は C ランタイムのドキュメン
   トを参照してください; ("O_RDONLY" や "O_WRONLY" のような) フラグ定
   数は "os" モジュールでも定義されています。特に、Windows ではバイナ
   リモードでファイルを開く時に "O_BINARY" を加える必要があります。

   この関数は *dir_fd* パラメタで ディレクトリ記述子への相対パス をサ
   ポートしています。

   引数 "path", "mode", "flags" を指定して 監査イベント "open" を送出
   します。

   バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

   注釈:

     この関数は低水準の I/O 向けのものです。 通常の利用では、組み込み
     関数 "open()" を使用してください。 "open()" は "read()" や
     "write()" (そしてさらに多くの) メソッドを持つ *ファイルオブジェク
     ト* を返します。 ファイル記述子をファイルオブジェクトでラップする
     には "fdopen()" を使用してください。

   バージョン 3.3 で変更: 引数 *dir_fd* を追加しました。

   バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
   外を送出しなかった場合、この関数は "InterruptedError" 例外を送出す
   る代わりにシステムコールを再試行するようになりました (論拠について
   は **PEP 475** を参照してください)。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

以下の定数は "open()" 関数の *flags* 引数に利用します。これらの定数は
、ビット単位に OR 演算子 "|" で組み合わせることができます。一部、すべ
てのプラットフォームでは使用できない定数があります。利用可能かどうかや
使い方については、Unix では *open(2)*、Windows では MSDN を参照してく
ださい。

os.O_RDONLY
os.O_WRONLY
os.O_RDWR
os.O_APPEND
os.O_CREAT
os.O_EXCL
os.O_TRUNC

   上記の定数は Unix および Windows で利用可能です。

os.O_DSYNC
os.O_RSYNC
os.O_SYNC
os.O_NDELAY
os.O_NONBLOCK
os.O_NOCTTY
os.O_CLOEXEC

   上記の定数は Unix でのみ利用可能です。

   バージョン 3.3 で変更: 定数 "O_CLOEXEC" が追加されました。

os.O_BINARY
os.O_NOINHERIT
os.O_SHORT_LIVED
os.O_TEMPORARY
os.O_RANDOM
os.O_SEQUENTIAL
os.O_TEXT

   上記の定数は Windows でのみ利用可能です。

os.O_EVTONLY
os.O_FSYNC
os.O_SYMLINK
os.O_NOFOLLOW_ANY

   上記の定数は macOS でのみ利用可能です。

   バージョン 3.10 で変更: Add "O_EVTONLY", "O_FSYNC", "O_SYMLINK" and
   "O_NOFOLLOW_ANY" constants.

os.O_ASYNC
os.O_DIRECT
os.O_DIRECTORY
os.O_NOFOLLOW
os.O_NOATIME
os.O_PATH
os.O_TMPFILE
os.O_SHLOCK
os.O_EXLOCK

   上記の定数は拡張仕様であり、Cライブラリで定義されていない場合は利用
   できません。

   バージョン 3.4 で変更: "O_PATH" を、それをサポートするシステムで追
   加しました。また、 "O_TMPFILE" を追加しました (Linux Kernel 3.11 以
   降でのみ利用可能です)。

os.openpty()

   新しい擬似端末のペアを開きます。pty および tty を表すファイル記述子
   のペア "(master, slave)" を返します。新しいファイル記述子は 継承不
   可 です。(若干) 可搬性の高いアプローチには "pty" を使用してください
   。

   Availability: Unix, not WASI.

   バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

os.pipe()

   パイプを作成します。読み込み、書き込みに使うことの出来るファイル記
   述子のペア "(r, w)"  を返します。新しいファイル記述子は 継承不可 で
   す。

   Availability: Unix, Windows.

   バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

os.pipe2(flags, /)

   *flags* を設定したパイプをアトミックに作成します。*flags* には値
   "O_NONBLOCK" と "O_CLOEXEC" を一つ以上論理和指定できます。読み込み
   、書き込みに使うことの出来るファイル記述子のペア "(r, w)"  を返しま
   す。

   Availability: Unix, not WASI.

   Added in version 3.3.

os.posix_fallocate(fd, offset, len, /)

   *fd* で指定されたファイルに対し、開始位置 *offset* から *len* バイ
   ト分割り当てるに十分なディスクスペースを確保します。

   Availability: Unix.

   Added in version 3.3.

os.posix_fadvise(fd, offset, len, advice, /)

   データへアクセスする意思を、パターンを指定して宣言します。これによ
   りカーネルが最適化を行えるようになります。*advice* は *fd* で指定さ
   れたファイルに対し、開始位置 *offset* から *len* バイト分の領域に適
   用されます。*advice* には "POSIX_FADV_NORMAL"、
   "POSIX_FADV_SEQUENTIAL"、"POSIX_FADV_RANDOM"、"POSIX_FADV_NOREUSE"
   、"POSIX_FADV_WILLNEED"、または "POSIX_FADV_DONTNEED" のいずれか一
   つを指定します。

   Availability: Unix.

   Added in version 3.3.

os.POSIX_FADV_NORMAL
os.POSIX_FADV_SEQUENTIAL
os.POSIX_FADV_RANDOM
os.POSIX_FADV_NOREUSE
os.POSIX_FADV_WILLNEED
os.POSIX_FADV_DONTNEED

   "posix_fadvise()" において、使われるであろうアクセスパターンを指定
   する *advice* に使用できるフラグです。

   Availability: Unix.

   Added in version 3.3.

os.pread(fd, n, offset, /)

   ファイル記述子の位置 *offset* から最大で *n* バイトを読み出します。
   ファイルオフセットは変化しません。

   読み込んだバイト分のバイト列を返します。 *fd* が参照しているファイ
   ルの終端に達した場合、空のバイト列が返されます。

   Availability: Unix.

   Added in version 3.3.

os.posix_openpt(oflag, /)

   Open and return a file descriptor for a master pseudo-terminal
   device.

   Calls the C standard library function "posix_openpt()". The *oflag*
   argument is used to set file status flags and file access modes as
   specified in the manual page of "posix_openpt()" of your system.

   The returned file descriptor is non-inheritable. If the value
   "O_CLOEXEC" is available on the system, it is added to *oflag*.

   Availability: Unix, not WASI.

   Added in version 3.13.

os.preadv(fd, buffers, offset, flags=0, /)

   ファイル記述子 *fd* の *offset* の位置から、可変な *bytes-like オブ
   ジェクト* *buffers* にオフセットを変更せずに読み込みます。 データを
   それぞれのバッファがいっぱいになるまで移し、いっぱいになったらシー
   ケンスの次のバッファに処理を移し、残りのデータを読み込ませます。

   flags 引数にはゼロあるいは次のフラグのバイトごとの OR を取った結果
   が保持されています。

   * "RWF_HIPRI"

   * "RWF_NOWAIT"

   実際に読み込んだ合計バイト数を返します。この値は、すべてのオブジェ
   クトの容量の総量よりも小さくなることがあります。

   オペレーティングシステムは、使用可能なバッファの個数に基づいて上限
   ("sysconf()" の "'SC_IOV_MAX'" の値) を設定することがあります。

   "os.readv()" と "os.pread()" の機能を統合します。

   Availability: Linux >= 2.6.30, FreeBSD >= 6.0, OpenBSD >= 2.7, AIX
   >= 7.1.

   Using flags requires Linux >= 4.6.

   Added in version 3.7.

os.RWF_NOWAIT

   即座に利用できないデータを待ちません。このフラグを指定すると、バッ
   クエンドのストレージからデータを読む必要があるか、ロックを待機する
   場合、システムコールは即座にリターンします。

   If some data was successfully read, it will return the number of
   bytes read. If no bytes were read, it will return "-1" and set
   errno to "errno.EAGAIN".

   Availability: Linux >= 4.14.

   Added in version 3.7.

os.RWF_HIPRI

   優先度の高い読み込み・書き込み (read/write) フラグです。ブロックス
   トレージに対して、追加のリソースを必要とする一方で低レイテンシなデ
   バイスのポーリングを使うことを許可します。

   現状、Linuxでは、ファイル記述子を "O_DIRECT" フラグを指定したオープ
   ンした場合でのみ、この機能を利用できます。

   Availability: Linux >= 4.6.

   Added in version 3.7.

os.ptsname(fd, /)

   Return the name of the slave pseudo-terminal device associated with
   the master pseudo-terminal device to which the file descriptor *fd*
   refers. The file descriptor *fd* is not closed upon failure.

   Calls the reentrant C standard library function "ptsname_r()" if it
   is available; otherwise, the C standard library function
   "ptsname()", which is not guaranteed to be thread-safe, is called.

   Availability: Unix, not WASI.

   Added in version 3.13.

os.pwrite(fd, str, offset, /)

   *str* 中のバイト文字列をファイル記述子 *fd* の *offset* の位置に書
   き込みます。ファイルオフセットを変化しません。

   実際に書き込まれたバイト数を返します。

   Availability: Unix.

   Added in version 3.3.

os.pwritev(fd, buffers, offset, flags=0, /)

   Write the *buffers* contents to file descriptor *fd* at an offset
   *offset*, leaving the file offset unchanged.  *buffers* must be a
   sequence of *bytes-like objects*. Buffers are processed in array
   order. Entire contents of the first buffer is written before
   proceeding to the second, and so on.

   flags 引数にはゼロあるいは次のフラグのバイトごとの OR を取った結果
   が保持されています。

   * "RWF_DSYNC"

   * "RWF_SYNC"

   * "RWF_APPEND"

   実際に書き込まれた合計バイト数を返します。

   オペレーティングシステムは、使用可能なバッファの個数に基づいて上限
   ("sysconf()" の "'SC_IOV_MAX'" の値) を設定することがあります。

   "os.writev()" と "os.pwrite()" の機能を統合します。

   Availability: Linux >= 2.6.30, FreeBSD >= 6.0, OpenBSD >= 2.7, AIX
   >= 7.1.

   Using flags requires Linux >= 4.6.

   Added in version 3.7.

os.RWF_DSYNC

   書き込みごとに "os.open()" の "O_DSYNC" と同等の効果を提供するフラ
   グです。このフラグはシステムコールによって書き込まれたデータ範囲に
   対してのみ適用されます。

   Availability: Linux >= 4.7.

   Added in version 3.7.

os.RWF_SYNC

   書き込みごとに "os.open()" の "O_SYNC" と同等の効果を提供するフラグ
   です。このフラグはシステムコールによって書き込まれたデータ範囲に対
   してのみ適用されます。

   Availability: Linux >= 4.7.

   Added in version 3.7.

os.RWF_APPEND

   Provide a per-write equivalent of the "O_APPEND" "os.open()" flag.
   This flag is meaningful only for "os.pwritev()", and its effect
   applies only to the data range written by the system call. The
   *offset* argument does not affect the write operation; the data is
   always appended to the end of the file. However, if the *offset*
   argument is "-1", the current file *offset* is updated.

   Availability: Linux >= 4.16.

   Added in version 3.10.

os.read(fd, n, /)

   ファイル記述子 *fd* から 最大 *n* バイトを読み込みます。

   読み込んだバイト分のバイト列を返します。 *fd* が参照しているファイ
   ルの終端に達した場合、空のバイト列が返されます。

   注釈:

     この関数は低水準の I/O 向けのもので、 "os.open()" や "pipe()" が
     返すファイル記述子に対して使用されなければなりません。 組み込み関
     数 "open()" や "popen()" 、 "fdopen()" 、あるいは "sys.stdin" が
     返す "ファイルオブジェクト" を読み込むには、オブジェクトの
     "read()" か "readline()" メソッドを使用してください。

   バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
   外を送出しなかった場合、この関数は "InterruptedError" 例外を送出す
   る代わりにシステムコールを再試行するようになりました (論拠について
   は **PEP 475** を参照してください)。

os.readinto(fd, buffer, /)

   Read from a file descriptor *fd* into a mutable buffer object
   *buffer*.

   The *buffer* should be mutable and *bytes-like*. On success,
   returns the number of bytes read. Less bytes may be read than the
   size of the buffer. The underlying system call will be retried when
   interrupted by a signal, unless the signal handler raises an
   exception. Other errors will not be retried and an error will be
   raised.

   Returns 0 if *fd* is at end of file or if the provided *buffer* has
   length 0 (which can be used to check for errors without reading
   data). Never returns negative.

   注釈:

     This function is intended for low-level I/O and must be applied
     to a file descriptor as returned by "os.open()" or "os.pipe()".
     To read a "file object" returned by the built-in function
     "open()", or "sys.stdin", use its member functions, for example
     "io.BufferedIOBase.readinto()", "io.BufferedIOBase.read()", or
     "io.TextIOBase.read()"

   Added in version 3.14.

os.sendfile(out_fd, in_fd, offset, count)
os.sendfile(out_fd, in_fd, offset, count, headers=(), trailers=(), flags=0)

   ファイル記述子 *in_fd* からファイル記述子 *out_fd* への開始位置
   *offset* へ *count* バイトコピーします。 送信バイト数を返します。
   EOF に達した場合は "0" を返します。

   前者の関数表記は "sendfile()" が定義されているすべてのプラットフォ
   ームでサポートされています。

   Linux では、*offset* に "None" が与えられると、バイト列は *in_fd*
   の現在の位置から読み込まれ、*in_fd* の位置は更新されます。

   後者は macOS および FreeBSD で使用される場合があります。*headers*
   および *trailers* は任意のバッファのシーケンス型オブジェクトで、
   *in_fd* からのデータが書き出される前と後に書き出されます。返り値は
   前者と同じです。

   macOS と FreeBSD では、*count* の値に "0" を指定すると、 *in_fd* の
   末尾に達するまで送信します。

   全てのプラットフォームはソケットをファイル記述子 *out_fd* としてサ
   ポートし、あるプラットフォームは他の種類 (例えば、通常のファイル、
   パイプ) も同様にサポートします。

   クロスプラットフォームのアプリケーションは *headers*、*trailers* な
   らびに *flags* 引数を使用するべきではありません。

   Availability: Unix, not WASI.

   注釈:

     "sendfile()" のより高水準のラッパについては
     "socket.socket.sendfile()" を参照してください。

   Added in version 3.3.

   バージョン 3.9 で変更: 引数 *out* と *in* は *out_fd* と *in_fd* に
   名前が変更されました。

os.SF_NODISKIO
os.SF_MNOWAIT
os.SF_SYNC

   実装がサポートしている場合 "sendfile()" 関数に渡すパラメーターです
   。

   Availability: Unix, not WASI.

   Added in version 3.3.

os.SF_NOCACHE

   Parameter to the "sendfile()" function, if the implementation
   supports it. The data won't be cached in the virtual memory and
   will be freed afterwards.

   Availability: Unix, not WASI.

   Added in version 3.11.

os.set_blocking(fd, blocking, /)

   指定されたファイル記述子のブロッキングモードを設定します。 ブロッキ
   ングが "False" の場合 "O_NONBLOCK" フラグを設定し、そうでない場合は
   クリアします。

   "get_blocking()" および "socket.socket.setblocking()" も参照してく
   ださい。

   Availability: Unix, Windows.

   The function is limited on WASI, see WebAssembly プラットフォーム
   for more information.

   On Windows, this function is limited to pipes.

   Added in version 3.5.

   バージョン 3.12 で変更: Added support for pipes on Windows.

os.splice(src, dst, count, offset_src=None, offset_dst=None, flags=0)

   Transfer *count* bytes from file descriptor *src*, starting from
   offset *offset_src*, to file descriptor *dst*, starting from offset
   *offset_dst*.

   The splicing behaviour can be modified by specifying a *flags*
   value. Any of the following variables may used, combined using
   bitwise OR (the "|" operator):

   * If "SPLICE_F_MOVE" is specified, the kernel is asked to move
     pages instead of copying, but pages may still be copied if the
     kernel cannot move the pages from the pipe.

   * If "SPLICE_F_NONBLOCK" is specified, the kernel is asked to not
     block on I/O. This makes the splice pipe operations nonblocking,
     but splice may nevertheless block because the spliced file
     descriptors may block.

   * If "SPLICE_F_MORE" is specified, it hints to the kernel that more
     data will be coming in a subsequent splice.

   At least one of the file descriptors must refer to a pipe. If
   *offset_src* is "None", then *src* is read from the current
   position; respectively for *offset_dst*. The offset associated to
   the file descriptor that refers to a pipe must be "None". The files
   pointed to by *src* and *dst* must reside in the same filesystem,
   otherwise an "OSError" is raised with "errno" set to "errno.EXDEV".

   このコピーは、カーネルからユーザースペースにデータを転送した後カー
   ネルに戻すという追加のコスト無しに完了します。 加えて、追加の最適化
   ができるファイルシステムもあります。 このコピーはファイルが両方とも
   バイナリファイルとして開かれたかのように行われます。

   Upon successful completion, returns the number of bytes spliced to
   or from the pipe. A return value of 0 means end of input. If *src*
   refers to a pipe, then this means that there was no data to
   transfer, and it would not make sense to block because there are no
   writers connected to the write end of the pipe.

   参考: The *splice(2)* man page.

   Availability: Linux >= 2.6.17 with glibc >= 2.5

   Added in version 3.10.

os.SPLICE_F_MOVE
os.SPLICE_F_NONBLOCK
os.SPLICE_F_MORE

   Added in version 3.10.

os.readv(fd, buffers, /)

   Read from a file descriptor *fd* into a number of mutable *bytes-
   like objects* *buffers*. Transfer data into each buffer until it is
   full and then move on to the next buffer in the sequence to hold
   the rest of the data.

   実際に読み込んだ合計バイト数を返します。この値は、すべてのオブジェ
   クトの容量の総量よりも小さくなることがあります。

   オペレーティングシステムは、使用可能なバッファの個数に基づいて上限
   ("sysconf()" の "'SC_IOV_MAX'" の値) を設定することがあります。

   Availability: Unix.

   Added in version 3.3.

os.tcgetpgrp(fd, /)

   *fd* ("os.open()" が返すオープンしたファイル記述子 ) で与えられる端
   末に関連付けられたプロセスグループを返します。

   Availability: Unix, not WASI.

os.tcsetpgrp(fd, pg, /)

   *fd* ("os.open()" が返すオープンしたファイル記述子 ) で与えられる端
   末に関連付けられたプロセスグループを *pg* に設定します。

   Availability: Unix, not WASI.

os.ttyname(fd, /)

   ファイル記述子 *fd* に関連付けられている端末デバイスを特定する文字
   列を返します。 *fd* が端末に関連付けられていない場合、例外が送出さ
   れます。

   Availability: Unix.

os.unlockpt(fd, /)

   Unlock the slave pseudo-terminal device associated with the master
   pseudo-terminal device to which the file descriptor *fd* refers.
   The file descriptor *fd* is not closed upon failure.

   Calls the C standard library function "unlockpt()".

   Availability: Unix, not WASI.

   Added in version 3.13.

os.write(fd, str, /)

   *str* のバイト列をファイル記述子 *fd* に書き出します。

   実際に書き込まれたバイト数を返します。

   注釈:

     この関数は低水準の I/O 向けのもので、 "os.open()" や "pipe()" が
     返すファイル記述子に対して使用しなければなりません。 組み込み関数
     "open()" や "popen()" 、 "fdopen()" 、あるいは "sys.stdout" や
     "sys.stderr" が返す "ファイルオブジェクト" に書き込むには、オブジ
     ェクトの "write()" メソッドを使用してください。

   バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
   外を送出しなかった場合、この関数は "InterruptedError" 例外を送出す
   る代わりにシステムコールを再試行するようになりました (論拠について
   は **PEP 475** を参照してください)。

os.writev(fd, buffers, /)

   *buffers* の内容をファイル記述子 *fd* へ書き出します。 *buffers* は
   *bytes-like オブジェクト* のシーケンスでなければなりません。バッフ
   ァは配列の順番で処理されます。最初のバッファの内容全体は 2 番目のバ
   ッファに進む前に書き込まれ、その次も同様です。

   実際に書き込まれた合計バイト数を返します。

   オペレーティングシステムは、使用可能なバッファの個数に基づいて上限
   ("sysconf()" の "'SC_IOV_MAX'" の値) を設定することがあります。

   Availability: Unix.

   Added in version 3.3.


ターミナルのサイズの問い合わせ
------------------------------

Added in version 3.3.

os.get_terminal_size(fd=STDOUT_FILENO, /)

   ターミナル (端末) のサイズ "(columns, lines)" を、"terminal_size"
   型のタプルで返します。

   オプションの引数 "fd" には問い合わせるファイル記述子を指定します (
   デフォルトは "STDOUT_FILENO"、または標準出力)。

   ファイル記述子が接続されていなかった場合、 "OSError" が送出されます
   。

   通常は高水準関数である "shutil.get_terminal_size()" を使用してくだ
   さい。"os.get_terminal_size" は低水準の実装です。

   Availability: Unix, Windows.

class os.terminal_size

   ターミナルウィンドウのサイズ "(columns, lines)" を保持するタプルの
   サブクラスです。

   columns

      ターミナルウィンドウの横幅 (文字数) です。

   lines

      ターミナルウィンドウの高さ (文字数) です。


ファイル記述子の継承
--------------------

Added in version 3.4.

ファイル記述子には「継承可能 (inheritable)」フラグというものがあって、
これにより子プロセスにファイル記述子が引き継がれるかどうかが決定されま
す。Python 3.4 より、 Python によって作成されるファイル記述子はデフォ
ルトで継承不可 (non-inheritable) となりました。

On UNIX, non-inheritable file descriptors are closed in child
processes at the execution of a new program, other file descriptors
are inherited. Note that non-inheritable file descriptors are still
*inherited* by child processes on "os.fork()".

Windows の場合は、標準ストリームを除き、継承不可のハンドルと継承不可の
ファイル記述子は子プロセスでクローズされます。標準ストリーム (ファイル
記述子の 0, 1, 2: 標準入力, 標準出力, 標準エラー出力) は常に引き継がれ
ます。 "spawn*" 関数を使う場合、全ての継承可能なハンドルと全ての継承可
能なファイル記述子は引き継がれます。 "subprocess" モジュールを使う場合
、標準ストリームを除く全てのファイル記述子はクローズされ、継承可能なハ
ンドルは *close_fds* 引数が "False" の場合にのみ引き継がれます。

On WebAssembly platforms, the file descriptor cannot be modified.

os.get_inheritable(fd, /)

   指定したファイル記述子の「継承可能 (inheritable)」フラグを取得しま
   す (boolean)。

os.set_inheritable(fd, inheritable, /)

   指定したファイル記述子の「継承可能 (inheritable)」フラグをセットし
   ます。

os.get_handle_inheritable(handle, /)

   指定したハンドルの「継承可能 (inheritable)」フラグを取得します
   (boolean)。

   Availability: Windows.

os.set_handle_inheritable(handle, inheritable, /)

   指定したハンドルの「継承可能 (inheritable)」フラグをセットします。

   Availability: Windows.


ファイルとディレクトリ
======================

一部の Unix プラットフォームでは、このセクションの関数の多くが以下の機
能を一つ以上サポートしています。

* **specifying a file descriptor:** Normally the *path* argument
  provided to functions in the "os" module must be a string specifying
  a file path.  However, some functions now alternatively accept an
  open file descriptor for their *path* argument. The function will
  then operate on the file referred to by the descriptor. For POSIX
  systems, Python will call the variant of the function prefixed with
  "f" (e.g. call "fchdir" instead of "chdir").

  "os.supports_fd" を使うことで、そのプラットフォーム上で *path* にフ
  ァイル記述子を指定できるかどうかを確認することができます。この機能が
  利用可能でない場合、 "os.supports_fd" の利用は "NotImplementedError"
  例外を送出します。

  その関数が引数に *dir_fd* または *follow_symlinks* もサポートしてい
  る場合、*path* にファイル記述子を指定した時にそれらのいずれかを指定
  するとエラーになります。

* **paths relative to directory descriptors:** If *dir_fd* is not
  "None", it should be a file descriptor referring to a directory, and
  the path to operate on should be relative; path will then be
  relative to that directory.  If the path is absolute, *dir_fd* is
  ignored.  For POSIX systems, Python will call the variant of the
  function with an "at" suffix and possibly prefixed with "f" (e.g.
  call "faccessat" instead of "access").

  そのプラットフォーム上で特別な関数に *dir_fd* がサポートされているか
  どうかは、"os.supports_dir_fd" で確認できます。利用できない場合
  "NotImplementedError" が送出されます。

* **not following symlinks:** If *follow_symlinks* is "False", and the
  last element of the path to operate on is a symbolic link, the
  function will operate on the symbolic link itself rather than the
  file pointed to by the link.  For POSIX systems, Python will call
  the "l..." variant of the function.

  そのプラットフォーム上で特別な関数に *follow_symlinks* がサポートさ
  れているかどうかは、"os.supports_follow_symlinks" で確認できます。利
  用できない場合 "NotImplementedError" が送出されます。

os.access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True)

   実 uid/gid を使って *path* に対するアクセスが可能か調べます。ほとん
   どのオペレーティングシステムは実効 uid/gid を使うため、このルーチン
   は suid/sgid 環境において、プログラムを起動したユーザーが *path* に
   対するアクセス権をもっているかを調べるために使われます。 *path* が
   存在するかどうかを調べるには *mode* を "F_OK" にします。ファイルア
   クセス権限 ( パーミッション ) を調べるには、 "R_OK", "W_OK", "X_OK"
   から一つまたはそれ以上のフラグを論理和指定でとることもできます。ア
   クセスが許可されている場合 "True" を、そうでない場合 "False" を返し
   ます。詳細は *access(2)* の Unix マニュアルページを参照してください
   。

   この関数は ディレクトリ記述子への相対パス および シンボリックリンク
   をたどらない をサポートしています。

   *effective_ids* が "True" の場合、"access()" は実 uid/gid ではなく
   実効 uid/gid を使用してアクセス権を調べます。プラットフォームによっ
   ては *effective_ids* がサポートされていない場合があります; サポート
   されているかどうかは "os.supports_effective_ids" で確認できます。利
   用できない場合 "NotImplementedError" が送出されます。

   注釈:

     ユーザーが、例えばファイルを開く権限を持っているかどうかを調べる
     ために実際に "open()" を行う前に "access()" を使用することはセキ
     ュリティホールの原因になります。なぜなら、調べた時点とオープンし
     た時点との時間差を利用してそのユーザーがファイルを不当に操作して
     しまうかもしれないからです。その場合は *EAFP* テクニックを利用す
     るのが望ましいやり方です。例えば

        if os.access("myfile", os.R_OK):
            with open("myfile") as fp:
                return fp.read()
        return "some default data"

     このコードは次のように書いたほうが良いです

        try:
            fp = open("myfile")
        except PermissionError:
            return "some default data"
        else:
            with fp:
                return fp.read()

   注釈:

     I/O 操作は "access()" が成功を示した時でも失敗することがあります
     。特にネットワークファイルシステムが通常の POSIX のパーミッション
     ビットモデルをはみ出すアクセス権限操作を備える場合にはそのような
     ことが起こりえます。

   バージョン 3.3 で変更: 引数 *dir_fd*、*effective_ids*、および
   *follow_symlinks* が追加されました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.F_OK
os.R_OK
os.W_OK
os.X_OK

   "access()" で *path* をテストする時に *mode* 引数に渡す値です。上か
   らそれぞれ、ファイルの存在、読み込み許可、書き込み許可、および実行
   許可になります。

os.chdir(path)

   現在の作業ディレクトリを *path* に設定します。

   この関数は ファイル記述子の指定 をサポートしています。記述子は、オ
   ープンしているファイルではなく、オープンしているディレクトリを参照
   していなければなりません。

   この関数は "OSError" やそのサブクラスである "FileNotFoundError",
   "PermissionError", "NotADirectoryError" などの例外を送出することが
   あります。

   引数 "path" を指定して 監査イベント "os.chdir" を送出します。

   バージョン 3.3 で変更: 一部のプラットフォームで、*path* にファイル
   記述子の指定をサポートしました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.chflags(path, flags, *, follow_symlinks=True)

   *path* のフラグを *flags* に変更します。 *flags* は、以下の値
   ("stat" モジュールで定義されているもの ) をビット単位の論理和で組み
   合わせることができます :

   * "stat.UF_NODUMP"

   * "stat.UF_IMMUTABLE"

   * "stat.UF_APPEND"

   * "stat.UF_OPAQUE"

   * "stat.UF_NOUNLINK"

   * "stat.UF_COMPRESSED"

   * "stat.UF_HIDDEN"

   * "stat.SF_ARCHIVED"

   * "stat.SF_IMMUTABLE"

   * "stat.SF_APPEND"

   * "stat.SF_NOUNLINK"

   * "stat.SF_SNAPSHOT"

   この関数は シンボリックリンクをたどらない をサポートしています。

   引数 "path", "flags" を指定して 監査イベント "os.chflags" を送出し
   ます。

   Availability: Unix, not WASI.

   バージョン 3.3 で変更: Added the *follow_symlinks* parameter.

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.chmod(path, mode, *, dir_fd=None, follow_symlinks=True)

   *path* のモードを数値 *mode* に変更します。 *mode* は、 ("stat" モ
   ジュールで定義されている ) 以下の値のいずれかまたはビット単位の論理
   和で組み合わせた値を取り得ます :

   * "stat.S_ISUID"

   * "stat.S_ISGID"

   * "stat.S_ENFMT"

   * "stat.S_ISVTX"

   * "stat.S_IREAD"

   * "stat.S_IWRITE"

   * "stat.S_IEXEC"

   * "stat.S_IRWXU"

   * "stat.S_IRUSR"

   * "stat.S_IWUSR"

   * "stat.S_IXUSR"

   * "stat.S_IRWXG"

   * "stat.S_IRGRP"

   * "stat.S_IWGRP"

   * "stat.S_IXGRP"

   * "stat.S_IRWXO"

   * "stat.S_IROTH"

   * "stat.S_IWOTH"

   * "stat.S_IXOTH"

   この関数は ファイル記述子の指定 、 ディレクトリ記述子への相対パス
   、および シンボリックリンクをたどらない をサポートしています。

   注釈:

     Although Windows supports "chmod()", you can only set the file's
     read-only flag with it (via the "stat.S_IWRITE" and
     "stat.S_IREAD" constants or a corresponding integer value).  All
     other bits are ignored. The default value of *follow_symlinks* is
     "False" on Windows.The function is limited on WASI, see
     WebAssembly プラットフォーム for more information.

   引数 "path", "mode", "dir_fd" を指定して 監査イベント "os.chmod" を
   送出します。

   バージョン 3.3 で変更: *path* にオープンしているファイル記述子の指
   定のサポート、および引数 *dir_fd* と *follow_symlinks* を追加しまし
   た。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

   バージョン 3.13 で変更: Added support for a file descriptor and the
   *follow_symlinks* argument on Windows.

os.chown(path, uid, gid, *, dir_fd=None, follow_symlinks=True)

   *path* の所有者 id およびグループ id を、数値 *uid* および *gid* に
   変更します。いずれかの id を変更せずにおくには、その値として -1 を
   指定します。

   この関数は ファイル記述子の指定 、 ディレクトリ記述子への相対パス
   、および シンボリックリンクをたどらない をサポートしています。

   数値 id の他に名前でも受け取る高水準関数の "shutil.chown()" を参照
   してください。

   引数 "path", "uid", "gid", "dir_fd" を指定して 監査イベント
   "os.chown" を送出します。

   Availability: Unix.

   The function is limited on WASI, see WebAssembly プラットフォーム
   for more information.

   バージョン 3.3 で変更: *path* にオープンしているファイル記述子の指
   定のサポート、および引数 *dir_fd* と *follow_symlinks* を追加しまし
   た。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.chroot(path)

   現在のプロセスのルートディレクトリを *path* に変更します。

   Availability: Unix, not WASI, not Android.

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.fchdir(fd)

   現在の作業ディレクトリをファイル記述子 *fd* が表すディレクトリに変
   更します。記述子はオープンしているファイルではなく、オープンしたデ
   ィレクトリを参照していなければなりません。Python 3.3 以降では
   "os.chdir(fd)" と等価です。

   引数 "path" を指定して 監査イベント "os.chdir" を送出します。

   Availability: Unix.

os.getcwd()

   現在の作業ディレクトリを表す文字列を返します。

os.getcwdb()

   現在の作業ディレクトリを表すバイト列を返します。

   バージョン 3.8 で変更: この関数は Windows において ANSI コードペー
   ジ ではなく UTF-8 エンコーディングを使うようになりました: 変更の背
   景については **PEP 529** をご覧ください。この関数は Windows におい
   て非推奨になりません。

os.lchflags(path, flags)

   *path* のフラグを数値 *flags* に設定します。"chflags()" に似ていま
   すが、シンボリックリンクをたどりません。Python 3.3 以降では
   "os.chflags(path, flags, follow_symlinks=False)" と等価です。

   引数 "path", "flags" を指定して 監査イベント "os.chflags" を送出し
   ます。

   Availability: Unix, not WASI.

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.lchmod(path, mode)

   *path* のモードを数値 *mode* に変更します。パスがシンボリックリンク
   の場合はそのリンク先ではなくシンボリックリンクそのものに対して作用
   します。*mode* に指定できる値については "chmod()" のドキュメントを
   参照してください。Python 3.3 以降では "os.chmod(path, mode,
   follow_symlinks=False)" と等価です。

   "lchmod()" is not part of POSIX, but Unix implementations may have
   it if changing the mode of symbolic links is supported.

   引数 "path", "mode", "dir_fd" を指定して 監査イベント "os.chmod" を
   送出します。

   Availability: Unix, Windows, not Linux, FreeBSD >= 1.3, NetBSD >=
   1.3, not OpenBSD

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

   バージョン 3.13 で変更: Added support on Windows.

os.lchown(path, uid, gid)

   *path* の所有者 id およびグループ id を、数値 *uid* および *gid* に
   変更します。この関数はシンボリックリンクをたどりません。Python 3.3
   以降では "os.chown(path, uid, gid, follow_symlinks=False)" と等価で
   す。

   引数 "path", "uid", "gid", "dir_fd" を指定して 監査イベント
   "os.chown" を送出します。

   Availability: Unix.

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.link(src, dst, *, src_dir_fd=None, dst_dir_fd=None, follow_symlinks=True)

   *src* を指し示すハードリンク *dst* を作成します。

   This function can support specifying *src_dir_fd* and/or
   *dst_dir_fd* to supply paths relative to directory descriptors, and
   not following symlinks. The default value of *follow_symlinks* is
   "False" on Windows.

   引数 "src", "dst", "src_dir_fd", "dst_dir_fd" を指定して 監査イベン
   ト "os.link" を送出します。

   Availability: Unix, Windows.

   バージョン 3.2 で変更: Windows サポートを追加しました。

   バージョン 3.3 で変更: Added the *src_dir_fd*, *dst_dir_fd*, and
   *follow_symlinks* parameters.

   バージョン 3.6 で変更: *src* と *dst* が *path-like object* を受け
   付けるようになりました。

os.listdir(path='.')

   *path* に指定したディレクトリに含まれるエントリ名のリストを返します
   。リストの順番は不定です。特別なエントリ "'.'" と "'..'" はリストに
   含まれません。この関数の呼び出し中にディレクトリからファイルが削除
   されたり、ディレクトリにファイルが追加されたりした場合、それらのフ
   ァイルがリストに含まれるかどうかは不定です。

   *path* に *path-like オブジェクト* を指定することもできます。
   *path* が  (直接的または間接的に "PathLike" インターフェースを介し
   た) "bytes" 型の場合、戻り値のファイル名も "bytes" 型になります; そ
   れ以外の場合、ファイル名は "str" 型です。

   この関数は ファイル記述子の指定 もサポートしています; ファイル記述
   子はディレクトリを参照していなくてはなりません。

   引数 "path" を指定して 監査イベント "os.listdir" を送出します。

   注釈:

     "文字列型" のファイル名を "バイト列型" にエンコードするには、
     "fsencode()" を使用します。

   参考:

     ディレクトリエントリに加えてファイル属性情報も返す "scandir()" 関
     数の方が、多くの一般的な用途では使い勝手が良くなります。

   バージョン 3.2 で変更: 引数 *path* は任意になりました。

   バージョン 3.3 で変更: *path* へのオープン・ファイル記述子の指定を
   サポートしました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.listdrives()

   Return a list containing the names of drives on a Windows system.

   A drive name typically looks like "'C:\\'". Not every drive name
   will be associated with a volume, and some may be inaccessible for
   a variety of reasons, including permissions, network connectivity
   or missing media. This function does not test for access.

   May raise "OSError" if an error occurs collecting the drive names.

   Raises an auditing event "os.listdrives" with no arguments.

   Availability: Windows

   Added in version 3.12.

os.listmounts(volume)

   Return a list containing the mount points for a volume on a Windows
   system.

   *volume* must be represented as a GUID path, like those returned by
   "os.listvolumes()". Volumes may be mounted in multiple locations or
   not at all. In the latter case, the list will be empty. Mount
   points that are not associated with a volume will not be returned
   by this function.

   The mount points return by this function will be absolute paths,
   and may be longer than the drive name.

   Raises "OSError" if the volume is not recognized or if an error
   occurs collecting the paths.

   Raises an auditing event "os.listmounts" with argument "volume".

   Availability: Windows

   Added in version 3.12.

os.listvolumes()

   Return a list containing the volumes in the system.

   Volumes are typically represented as a GUID path that looks like
   "\\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\". Files can
   usually be accessed through a GUID path, permissions allowing.
   However, users are generally not familiar with them, and so the
   recommended use of this function is to retrieve mount points using
   "os.listmounts()".

   May raise "OSError" if an error occurs collecting the volumes.

   Raises an auditing event "os.listvolumes" with no arguments.

   Availability: Windows

   Added in version 3.12.

os.lstat(path, *, dir_fd=None)

   Perform the equivalent of an "lstat()" system call on the given
   path. Similar to "stat()", but does not follow symbolic links.
   Return a "stat_result" object.

   シンボリックリンクをサポートしていないプラットフォームでは "stat()"
   の別名です。

   Python 3.3 以降では "os.stat(path, dir_fd=dir_fd,
   follow_symlinks=False)" と等価です。

   この関数は ディレクトリ記述子への相対パス もサポートすることができ
   ます。

   参考: "stat()" 関数。

   バージョン 3.2 で変更: Windows 6.0 (Vista) のシンボリックリンクをサ
   ポートしました。

   バージョン 3.3 で変更: 引数 *dir_fd* を追加しました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

   バージョン 3.8 で変更: On Windows, now opens reparse points that
   represent another path (name surrogates), including symbolic links
   and directory junctions. Other kinds of reparse points are resolved
   by the operating system as for "stat()".

os.mkdir(path, mode=0o777, *, dir_fd=None)

   ディレクトリ *path* を数値モード *mode* で作成します。

   If the directory already exists, "FileExistsError" is raised. If a
   parent directory in the path does not exist, "FileNotFoundError" is
   raised.

   いくつかのシステムにおいては *mode* は無視されます。それが使われる
   時には、最初に現在の umask 値でマスクされます。もし最後の 9 ビット
   (つまり *mode* の8進法表記の最後の3桁) を除いたビットが設定されてい
   たら、それらの意味はプラットフォームに依存します。いくつかのプラッ
   トフォームではそれらは無視され、それらを設定するためには明示的に
   "chmod()" を呼ぶ必要があるでしょう。

   On Windows, a *mode* of "0o700" is specifically handled to apply
   access control to the new directory such that only the current user
   and administrators have access. Other values of *mode* are ignored.

   この関数は ディレクトリ記述子への相対パス もサポートすることができ
   ます。

   一時ディレクトリを作成することもできます : "tempfile" モジュールの
   "tempfile.mkdtemp()" 関数を参照してください。

   引数 "path", "mode", "dir_fd" を指定して 監査イベント "os.mkdir" を
   送出します。

   バージョン 3.3 で変更: 引数 *dir_fd* を追加しました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

   バージョン 3.13 で変更: Windows now handles a *mode* of "0o700".

os.makedirs(name, mode=0o777, exist_ok=False)

   再帰的にディレクトリを作成する関数です。"mkdir()" と似ていますが、
   末端ディレクトリを作成するために必要なすべての中間ディレクトリも作
   成します。

   The *mode* parameter is passed to "mkdir()" for creating the leaf
   directory; see the mkdir() description for how it is interpreted.
   To set the file permission bits of any newly created parent
   directories you can set the umask before invoking "makedirs()".
   The file permission bits of existing parent directories are not
   changed.

   *exist_ok* の値が "False" の場合 (デフォルト)、対象のディレクトリが
   すでに存在すると "FileExistsError" を送出します。

   注釈:

     作成するパス要素に "pardir" (UNIX では "..") が含まれる場合、
     "makedirs()" は混乱します。

   この関数は UNC パスを正しく扱えるようになりました。

   引数 "path", "mode", "dir_fd" を指定して 監査イベント "os.mkdir" を
   送出します。

   バージョン 3.2 で変更: Added the *exist_ok* parameter.

   バージョン 3.4.1 で変更: Python 3.4.1 より前、 *exist_ok* が "True"
   でそのディレクトリが既存の場合でも、 "makedirs()" は *mode* が既存
   ディレクトリのモードと合わない場合にはエラーにしようとしていました
   。このモードチェックの振る舞いを安全に実装することが出来なかったた
   め、 Python 3.4.1 でこのチェックは削除されました。 bpo-21082 を参照
   してください。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

   バージョン 3.7 で変更: The *mode* argument no longer affects the
   file permission bits of newly created intermediate-level
   directories.

os.mkfifo(path, mode=0o666, *, dir_fd=None)

   FIFO (名前付きパイプ) *path* を数値モード *mode* で作成します。先に
   現在の umask 値でマスクされます。

   この関数は ディレクトリ記述子への相対パス もサポートすることができ
   ます。

   FIFO は通常のファイルのようにアクセスできるパイプです。 FIFO は (
   例えば "os.unlink()" を使って ) 削除されるまで存在しつづけます。一
   般的に、 FIFO は " クライアント " と " サーバー " 形式のプロセス間
   でランデブーを行うために使われます : この時、サーバーは FIFO を読み
   込み用に、クライアントは書き出し用にオープンします。 "mkfifo()" は
   FIFO をオープンしない --- 単にランデブーポイントを作成するだけ ---
   なので注意してください。

   Availability: Unix, not WASI.

   バージョン 3.3 で変更: 引数 *dir_fd* を追加しました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.mknod(path, mode=0o600, device=0, *, dir_fd=None)

   *path* という名前で、ファイルシステムノード (ファイル、デバイス特殊
   ファイル、または名前つきパイプ) を作成します。*mode* は、作成するノ
   ードのアクセス権限とタイプの両方を "stat.S_IFREG"、"stat.S_IFCHR"、
   "stat.S_IFBLK"、および "stat.S_IFIFO" の組み合わせ (ビット単位の論
   理和) で指定します (これらの定数は "stat" で利用可能です)。
   "stat.S_IFCHR" と "stat.S_IFBLK" を指定した場合、*devide* は新しく
   作成されたデバイス特殊ファイルを (おそらく "os.makedev()" を使って)
   定義し、それ以外の定数を指定した場合は無視されます。

   この関数は ディレクトリ記述子への相対パス もサポートすることができ
   ます。

   Availability: Unix, not WASI.

   バージョン 3.3 で変更: 引数 *dir_fd* を追加しました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.major(device, /)

   Extract the device major number from a raw device number (usually
   the "st_dev" or "st_rdev" field from "stat").

os.minor(device, /)

   Extract the device minor number from a raw device number (usually
   the "st_dev" or "st_rdev" field from "stat").

os.makedev(major, minor, /)

   メジャーおよびマイナーデバイス番号から、新しく RAW デバイス番号を作
   成します。

os.pathconf(path, name)

   名前付きファイルに関連するシステム設定情報を返します。 *name* には
   取得したい設定名を指定します ; これは定義済みのシステム値名の文字列
   で、多くの標準 (POSIX.1 、 Unix 95 、 Unix 98 その他 ) で定義されて
   います。プラットフォームによっては別の名前も定義しています。ホスト
   オペレーティングシステムの関知する名前は "pathconf_names" 辞書で与
   えられています。このマップ型オブジェクトに入っていない設定変数につ
   いては、 *name* に整数を渡してもかまいません。

   *name* が不明の文字列である場合、 "ValueError" を送出します。
   *name* の特定の値がホストシステムでサポートされていない場合、
   "pathconf_names" に含まれていたとしても、 "errno.EINVAL" をエラー番
   号として "OSError" を送出します。

   この関数は ファイル記述子の指定 をサポートしています。

   Availability: Unix.

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.pathconf_names

   "pathconf()" および "fpathconf()" が受理するシステム設定名を、ホス
   トオペレーティングシステムで定義されている整数値に対応付けている辞
   書です。この辞書はシステムでどの設定名が定義されているかを知るため
   に利用できます。

   Availability: Unix.

os.readlink(path, *, dir_fd=None)

   シンボリックリンクが指しているパスを表す文字列を返します。返される
   値は絶対パスにも、相対パスにもなり得ます ; 相対パスの場合、
   "os.path.join(os.path.dirname(path), result)" を使って絶対パスに変
   換することができます。

   If the *path* is a string object (directly or indirectly through a
   "PathLike" interface), the result will also be a string object, and
   the call may raise a UnicodeDecodeError. If the *path* is a bytes
   object (direct or indirectly), the result will be a bytes object.

   この関数は ディレクトリ記述子への相対パス もサポートすることができ
   ます。

   When trying to resolve a path that may contain links, use
   "realpath()" to properly handle recursion and platform differences.

   Availability: Unix, Windows.

   バージョン 3.2 で変更: Windows 6.0 (Vista) のシンボリックリンクをサ
   ポートしました。

   バージョン 3.3 で変更: 引数 *dir_fd* を追加しました。

   バージョン 3.6 で変更: Unixで、 *path-like object* を受け入れるよう
   になりました。

   バージョン 3.8 で変更: Windowsで、 *path-like object* と bytes オブ
   ジェクトを受け入れるようになりました。Added support for directory
   junctions, and changed to return the substitution path (which
   typically includes "\\?\" prefix) rather than the optional "print
   name" field that was previously returned.

os.remove(path, *, dir_fd=None)

   Remove (delete) the file *path*.  If *path* is a directory, an
   "OSError" is raised.  Use "rmdir()" to remove directories. If the
   file does not exist, a "FileNotFoundError" is raised.

   この関数は ディレクトリ記述子への相対パス をサポートしています。

   Windows では、使用中のファイルを削除しようとすると例外を送出します;
   Unixでは、ディレクトリエントリは削除されますが、記憶装置上に割り当
   てられたファイル領域は元のファイルが使われなくなるまで残されます。

   この関数は意味論的に "unlink()" と同一です。

   引数 "path", "dir_fd" を指定して 監査イベント "os.remove" を送出し
   ます。

   バージョン 3.3 で変更: 引数 *dir_fd* を追加しました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.removedirs(name)

   再帰的なディレクトリ削除関数です。 "rmdir()" と同じように動作します
   が、末端ディレクトリがうまく削除できるかぎり、 "removedirs()" は
   *path* に現れる親ディレクトリをエラーが送出されるまで ( このエラー
   は通常、指定したディレクトリの親ディレクトリが空でないことを意味す
   るだけなので無視されます ) 順に削除することを試みます。例えば、
   "os.removedirs('foo/bar/baz')" では最初にディレクトリ
   "'foo/bar/baz'" を削除し、次に "'foo/bar'" さらに "'foo'" をそれら
   が空ならば削除します。末端のディレクトリが削除できなかった場合には
   "OSError" が送出されます。

   引数 "path", "dir_fd" を指定して 監査イベント "os.remove" を送出し
   ます。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.rename(src, dst, *, src_dir_fd=None, dst_dir_fd=None)

   Rename the file or directory *src* to *dst*. If *dst* exists, the
   operation will fail with an "OSError" subclass in a number of
   cases:

   On Windows, if *dst* exists a "FileExistsError" is always raised.
   The operation may fail if *src* and *dst* are on different
   filesystems. Use "shutil.move()" to support moves to a different
   filesystem.

   On Unix, if *src* is a file and *dst* is a directory or vice-versa,
   an "IsADirectoryError" or a "NotADirectoryError" will be raised
   respectively.  If both are directories and *dst* is empty, *dst*
   will be silently replaced.  If *dst* is a non-empty directory, an
   "OSError" is raised. If both are files, *dst* will be replaced
   silently if the user has permission.  The operation may fail on
   some Unix flavors if *src* and *dst* are on different filesystems.
   If successful, the renaming will be an atomic operation (this is a
   POSIX requirement).

   この関数は *src_dir_fd* と *dst_dir_fd* のどちらかまたは両方の指定
   に ディレクトリ記述子への相対パス をサポートしています。

   対象の上書きがクロスプラットフォームになる場合は "replace()" を使用
   してください。

   引数 "src", "dst", "src_dir_fd", "dst_dir_fd" を指定して 監査イベン
   ト "os.rename" を送出します。

   バージョン 3.3 で変更: Added the *src_dir_fd* and *dst_dir_fd*
   parameters.

   バージョン 3.6 で変更: *src* と *dst* が *path-like object* を受け
   付けるようになりました。

os.renames(old, new)

   再帰的にディレクトリやファイル名を変更する関数です。 "rename()" の
   ように動作しますが、新たなパス名を持つファイルを配置するために必要
   な途中のディレクトリ構造をまず作成しようと試みます。名前変更の後、
   元のファイル名のパス要素は "removedirs()" を使って右側から順に削除
   されます。

   注釈:

     この関数はコピー元の末端のディレクトリまたはファイルを削除する権
     限がない場合には失敗します。

   引数 "src", "dst", "src_dir_fd", "dst_dir_fd" を指定して 監査イベン
   ト "os.rename" を送出します。

   バージョン 3.6 で変更: *old* と *new* が *path-like object* を受け
   付けるようになりました。

os.replace(src, dst, *, src_dir_fd=None, dst_dir_fd=None)

   ファイルまたはディレクトリ *src* の名前を *dst* へ変更します。*dst*
   が空でないディレクトリの場合 "OSError" が送出されます。*dst* が存在
   し、かつファイルの場合、ユーザーの権限がある限り暗黙のうちに置き換
   えられます。*src* と *dst* が異なるファイルシステム上にあると失敗す
   ることがあります。ファイル名の変更が成功する場合はアトミック操作と
   なります (これは POSIX 要求仕様です)。

   この関数は *src_dir_fd* と *dst_dir_fd* のどちらかまたは両方の指定
   に ディレクトリ記述子への相対パス をサポートしています。

   引数 "src", "dst", "src_dir_fd", "dst_dir_fd" を指定して 監査イベン
   ト "os.rename" を送出します。

   Added in version 3.3.

   バージョン 3.6 で変更: *src* と *dst* が *path-like object* を受け
   付けるようになりました。

os.rmdir(path, *, dir_fd=None)

   Remove (delete) the directory *path*.  If the directory does not
   exist or is not empty, a "FileNotFoundError" or an "OSError" is
   raised respectively.  In order to remove whole directory trees,
   "shutil.rmtree()" can be used.

   この関数は ディレクトリ記述子への相対パス をサポートしています。

   引数 "path", "dir_fd" を指定して 監査イベント "os.rmdir" を送出しま
   す。

   バージョン 3.3 で変更: 引数 *dir_fd* を追加しました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.scandir(path='.')

   Return an iterator of "os.DirEntry" objects corresponding to the
   entries in the directory given by *path*. The entries are yielded
   in arbitrary order, and the special entries "'.'" and "'..'" are
   not included.  If a file is removed from or added to the directory
   after creating the iterator, whether an entry for that file be
   included is unspecified.

   "listdir()" の代わりに "scandir()" を使用すると、ファイルタイプや属
   性情報も必要とするコードのパフォーマンスが大幅に向上します。これは
   、オペレーティングシステムがディレクトリのスキャン中にこの情報を提
   供した場合、"os.DirEntry" オブジェクトがその情報を公開するからです
   。すべての "os.DirEntry" メソッドはシステムコールを実行する場合があ
   りますが、"is_dir()" と "is_file()" は、通常はシンボリックリンクに
   しかシステムコールを必要としません。"os.DirEntry.stat()" は、Unix
   上では常にシステムコールを必要としますが、Windows ではシンボリック
   リンク用にシステムコールを一つ必要とするだけです。

   *path* may be a *path-like object*.  If *path* is of type "bytes"
   (directly or indirectly through the "PathLike" interface), the type
   of the "name" and "path" attributes of each "os.DirEntry" will be
   "bytes"; in all other circumstances, they will be of type "str".

   この関数は ファイル記述子の指定 もサポートしています; ファイル記述
   子はディレクトリを参照していなくてはなりません。

   引数 "path" を指定して 監査イベント "os.scandir" を送出します。

   "scandir()" イテレータは、 *コンテキストマネージャ* プロトコルをサ
   ポートし、次のメソッドを持ちます。

   scandir.close()

      イテレータを閉じ、獲得した資源を開放します。

      この関数は、イテレータがすべて消費されるか、ガーベージコレクトさ
      れた、もしくはイテレート中にエラーが発生した際に自動的に呼び出さ
      れます。しかし、 "with" 文を用いるか、明示的に呼び出すことを推奨
      します。

      Added in version 3.6.

   次の単純な例では、"scandir()" を使用して、指定した *path* 内の先頭
   が "'.'" でないすべてのファイル (ディレクトリを除く) をすべて表示し
   ます。"entry.is_file()" を呼び出しても、通常は追加のシステムコール
   は行われません:

      with os.scandir(path) as it:
          for entry in it:
              if not entry.name.startswith('.') and entry.is_file():
                  print(entry.name)

   注釈:

     On Unix-based systems, "scandir()" uses the system's opendir()
     and readdir() functions. On Windows, it uses the Win32
     FindFirstFileW and FindNextFileW functions.

   Added in version 3.5.

   バージョン 3.6 で変更: Added support for the *context manager*
   protocol and the "close()" method.  If a "scandir()" iterator is
   neither exhausted nor explicitly closed a "ResourceWarning" will be
   emitted in its destructor.関数が *path-like object* を受け入れるよ
   うになりました。

   バージョン 3.7 で変更: Unix で ファイル記述子の指定 のサポートが追
   加されました。

class os.DirEntry

   ディレクトリエントリのファイルパスとその他のファイル属性を公開する
   ために、"scandir()" が yield するオブジェクトです。

   "scandir()" は、追加のシステムコールを実行することなく、この情報を
   できるだけ多く提供します。"stat()" または "lstat()" システムコール
   が実行された場合、"os.DirEntry" オブジェクトは結果をキャッシュしま
   す。

   "os.DirEntry" インスタンスは、寿命の長いデータ構造に保存されること
   は想定されていません。ファイルメタデータが変更された場合や、
   "scandir()" が呼び出されてから長時間が経過した場合は、
   "os.stat(entry.path)" を呼び出して最新の情報を取得してください。

   "os.DirEntry" のメソッドはオペレーティングシステムコールを実行する
   場合があるため、それらは "OSError" も送出する場合があります。エラー
   を細かく制御する必要がある場合、 "os.DirEntry" のメソッドの一つの呼
   び出し時に "OSError" を捕捉して、適切な処理を行うことができます。

   To be directly usable as a *path-like object*, "os.DirEntry"
   implements the "PathLike" interface.

   "os.DirEntry" インスタンスの属性とメソッドは以下の通りです:

   name

      "scandir()" の *path* 引数に対して相対的な、エントリのベースファ
      イル名です。

      The "name" attribute will be "bytes" if the "scandir()" *path*
      argument is of type "bytes" and "str" otherwise.  Use
      "fsdecode()" to decode byte filenames.

   path

      The entry's full path name: equivalent to
      "os.path.join(scandir_path, entry.name)" where *scandir_path* is
      the "scandir()" *path* argument.  The path is only absolute if
      the "scandir()" *path* argument was absolute.  If the
      "scandir()" *path* argument was a file descriptor, the "path"
      attribute is the same as the "name" attribute.

      The "path" attribute will be "bytes" if the "scandir()" *path*
      argument is of type "bytes" and "str" otherwise.  Use
      "fsdecode()" to decode byte filenames.

   inode()

      項目の inode 番号を返します。

      結果は "os.DirEntry" オブジェクトにキャッシュされます。最新の情
      報を取得するには "os.stat(entry.path,
      follow_symlinks=False).st_ino" を使用してください。

      Windows 上では、最初のキャッシュされていない呼び出しでシステムコ
      ールが必要ですが、 Unix 上では必要ありません。

   is_dir(*, follow_symlinks=True)

      この項目がディレクトリまたはディレクトリへのシンボリックリンクで
      ある場合、 "True" を返します。項目がそれ以外のファイルやそれ以外
      のファイルへのシンボリックリンクである場合や、もはや存在しない場
      合は "False" を返します。

      *follow_symlinks* が "False" の場合、項目がディレクトリ (シンボ
      リックリンクはたどりません) の場合にのみ "True" を返します。項目
      がディレクトリ以外のファイルである場合や、項目がもはや存在しない
      場合は "False" を返します。

      結果は "os.DirEntry" オブジェクトにキャッシュされます。
      *follow_symlinks* が "True" の場合と "False" の場合とでは、別の
      オブジェクトにキャッシュされます。最新の情報を取得するには
      "stat.S_ISDIR()" と共に "os.stat()" を呼び出してください。

      多くの場合、最初のキャッシュされない呼び出しでは、システムコール
      は必要とされません。具体的には、シンボリックリンク以外では、
      Windows も Unix もシステムコールを必要としません。ただし、
      "dirent.d_type == DT_UNKNOWN" を返す、ネットワークファイルシステ
      ムなどの特定の Unix ファイルシステムは例外です。項目がシンボリッ
      クリンクの場合、*follow_symlinks* が "False" の場合を除き、シン
      ボリックリンクをたどるためにシステムコールが必要となります。

      このメソッドは "PermissionError" のような "OSError" を送出するこ
      とがありますが、 "FileNotFoundError" は捕捉され送出されません。

   is_file(*, follow_symlinks=True)

      この項目がファイルまたはファイルへのシンボリックリンクである場合
      、 "True" を返します。項目がディレクトリやファイル以外の項目への
      シンボリックリンクである場合や、もはや存在しない場合は "False"
      を返します。

      *follow_symlinks* が "False" の場合、項目がファイル (シンボリッ
      クリンクはたどりません) の場合にのみ "True" を返します。項目がデ
      ィレクトリやその他のファイル以外の項目である場合や、項目がもはや
      存在しない場合は "False" を返します。

      結果は "os.DirEntry" オブジェクトにキャッシュされます。キャッシ
      ュ、システムコール、例外は、"is_dir()" と同様に行われます。

   is_symlink()

      この項目がシンボリックリンクの場合 (たとえ破損していても)、
      "True" を返します。項目がディレクトリやあらゆる種類のファイルの
      場合、またはもはや存在しない場合は "False" を返します。

      結果は "os.DirEntry" オブジェクトにキャッシュされます。 最新の情
      報をフェッチするには "os.path.islink()" を呼び出してください。

      多くの場合、最初のキャッシュされない呼び出しでは、システムコール
      は必要とされません。具体的には、Windows も Unix もシステムコール
      を必要としません。ただし、"dirent.d_type == DT_UNKNOWN" を返す、
      ネットワークファイルシステムなどの特定の Unix ファイルシステムは
      例外です。

      このメソッドは "PermissionError" のような "OSError" を送出するこ
      とがありますが、 "FileNotFoundError" は捕捉され送出されません。

   is_junction()

      Return "True" if this entry is a junction (even if broken);
      return "False" if the entry points to a regular directory, any
      kind of file, a symlink, or if it doesn't exist anymore.

      The result is cached on the "os.DirEntry" object. Call
      "os.path.isjunction()" to fetch up-to-date information.

      Added in version 3.12.

   stat(*, follow_symlinks=True)

      この項目の "stat_result" オブジェクトを返します。このメソッドは
      、デフォルトでシンボリックリンクをたどります。シンボリックリンク
      を開始するには、 "follow_symlinks=False" 引数を追加します。

      On Unix, this method always requires a system call. On Windows,
      it only requires a system call if *follow_symlinks* is "True"
      and the entry is a reparse point (for example, a symbolic link
      or directory junction).

      Windows では、"stat_result" の "st_ino" 、 "st_dev" 、
      "st_nlink" 属性は常にゼロに設定されます。これらの属性を取得する
      には、 "os.stat()" を呼び出します。

      結果は "os.DirEntry" オブジェクトにキャッシュされます。
      *follow_symlinks* が "True" の場合と "False" の場合とでは、別の
      オブジェクトにキャッシュされます。最新の情報を取得するには、
      "os.stat()" を呼び出してください。

   Note that there is a nice correspondence between several attributes
   and methods of "os.DirEntry" and of "pathlib.Path".  In particular,
   the "name" attribute has the same meaning, as do the "is_dir()",
   "is_file()", "is_symlink()", "is_junction()", and "stat()" methods.

   Added in version 3.5.

   バージョン 3.6 で変更: "PathLike" インターフェースをサポートしまし
   た。Windowsで "bytes" パスをサポートしました。

   バージョン 3.12 で変更: The "st_ctime" attribute of a stat result
   is deprecated on Windows. The file creation time is properly
   available as "st_birthtime", and in the future "st_ctime" may be
   changed to return zero or the metadata change time, if available.

os.stat(path, *, dir_fd=None, follow_symlinks=True)

   Get the status of a file or a file descriptor. Perform the
   equivalent of a "stat()" system call on the given path. *path* may
   be specified as either a string or bytes -- directly or indirectly
   through the "PathLike" interface -- or as an open file descriptor.
   Return a "stat_result" object.

   この関数は通常はシンボリックリンクをたどります。シンボリックリンク
   に対して stat したい場合は "follow_symlinks=False" とするか、
   "lstat()" を利用してください。

   この関数は ファイル記述子の指定 および シンボリックリンクをたどらな
   い をサポートしています。

   On Windows, passing "follow_symlinks=False" will disable following
   all name-surrogate reparse points, which includes symlinks and
   directory junctions. Other types of reparse points that do not
   resemble links or that the operating system is unable to follow
   will be opened directly. When following a chain of multiple links,
   this may result in the original link being returned instead of the
   non-link that prevented full traversal. To obtain stat results for
   the final path in this case, use the "os.path.realpath()" function
   to resolve the path name as far as possible and call "lstat()" on
   the result. This does not apply to dangling symlinks or junction
   points, which will raise the usual exceptions.

   以下はプログラム例です:

      >>> import os
      >>> statinfo = os.stat('somefile.txt')
      >>> statinfo
      os.stat_result(st_mode=33188, st_ino=7876932, st_dev=234881026,
      st_nlink=1, st_uid=501, st_gid=501, st_size=264, st_atime=1297230295,
      st_mtime=1297230027, st_ctime=1297230027)
      >>> statinfo.st_size
      264

   参考: "fstat()" と "lstat()"。

   バージョン 3.3 で変更: Added the *dir_fd* and *follow_symlinks*
   parameters, specifying a file descriptor instead of a path.

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

   バージョン 3.8 で変更: On Windows, all reparse points that can be
   resolved by the operating system are now followed, and passing
   "follow_symlinks=False" disables following all name surrogate
   reparse points. If the operating system reaches a reparse point
   that it is not able to follow, *stat* now returns the information
   for the original path as if "follow_symlinks=False" had been
   specified instead of raising an error.

class os.stat_result

   Object whose attributes correspond roughly to the members of the
   "stat" structure. It is used for the result of "os.stat()",
   "os.fstat()" and "os.lstat()".

   属性:

   st_mode

      ファイルモード。ファイルタイプとファイルモードのビット （権限）
      。

   st_ino

      Platform dependent, but if non-zero, uniquely identifies the
      file for a given value of "st_dev". Typically:

      * the inode number on Unix,

      * the file index on Windows

   st_dev

      このファイルが存在するデバイスの識別子。

   st_nlink

      ハードリンクの数。

   st_uid

      ファイル所有者のユーザ識別子。

   st_gid

      ファイル所有者のグループ識別子。

   st_size

      ファイルが通常のファイルまたはシンボリックリンクの場合、そのファ
      イルのバイト単位でのサイズです。シンボリックリンクのサイズは、含
      まれるパス名の長さで、null バイトで終わることはありません。

   タイムスタンプ:

   st_atime

      秒で表した最終アクセス時刻。

   st_mtime

      秒で表した最終内容更新時刻。

   st_ctime

      Time of most recent metadata change expressed in seconds.

      バージョン 3.12 で変更: "st_ctime" is deprecated on Windows. Use
      "st_birthtime" for the file creation time. In the future,
      "st_ctime" will contain the time of the most recent metadata
      change, as for other platforms.

   st_atime_ns

      ナノ秒 (整数) で表した最終アクセス時刻。

      Added in version 3.3.

   st_mtime_ns

      ナノ秒 (整数) で表した最終内容更新時刻。

      Added in version 3.3.

   st_ctime_ns

      Time of most recent metadata change expressed in nanoseconds as
      an integer.

      Added in version 3.3.

      バージョン 3.12 で変更: "st_ctime_ns" is deprecated on Windows.
      Use "st_birthtime_ns" for the file creation time. In the future,
      "st_ctime" will contain the time of the most recent metadata
      change, as for other platforms.

   st_birthtime

      Time of file creation expressed in seconds. This attribute is
      not always available, and may raise "AttributeError".

      バージョン 3.12 で変更: "st_birthtime" is now available on
      Windows.

   st_birthtime_ns

      Time of file creation expressed in nanoseconds as an integer.
      This attribute is not always available, and may raise
      "AttributeError".

      Added in version 3.12.

   注釈:

     The exact meaning and resolution of the "st_atime", "st_mtime",
     "st_ctime" and "st_birthtime" attributes depend on the operating
     system and the file system. For example, on Windows systems using
     the FAT32 file systems, "st_mtime" has 2-second resolution, and
     "st_atime" has only 1-day resolution. See your operating system
     documentation for details.Similarly, although "st_atime_ns",
     "st_mtime_ns", "st_ctime_ns" and "st_birthtime_ns" are always
     expressed in nanoseconds, many systems do not provide nanosecond
     precision.  On systems that do provide nanosecond precision, the
     floating-point object used to store "st_atime", "st_mtime",
     "st_ctime" and "st_birthtime" cannot preserve all of it, and as
     such will be slightly inexact. If you need the exact timestamps
     you should always use "st_atime_ns", "st_mtime_ns", "st_ctime_ns"
     and "st_birthtime_ns".

   (Linux のような ) 一部の Unix システムでは、以下の属性が利用できる
   場合があります :

   st_blocks

      ファイルに対して割り当てられている 512 バイトのブロックの数です
      。ファイルにホール (hole) が含まれている場合、"st_size"/512 より
      小さくなる場合があります。

   st_blksize

      効率的なファイルシステム I/O のための「推奨される」ブロックサイ
      ズです。ファイルに、これより小さいチャンクで書き込むと、非効率的
      な読み込み、編集、再書き込みが起こる場合があります。

   st_rdev

      inode デバイスの場合デバイスタイプ

   st_flags

      ファイルのユーザ定義フラグ

   他の (FreeBSD のような ) Unix システムでは、以下の属性が利用できる
   場合があります ( ただし root ユーザ以外が使うと値が入っていない場合
   があります ):

   st_gen

      ファイル生成番号

   On Solaris and derivatives, the following attributes may also be
   available:

   st_fstype

      String that uniquely identifies the type of the filesystem that
      contains the file.

   On macOS systems, the following attributes may also be available:

   st_rsize

      ファイルの実際のサイズ

   st_creator

      ファイルの作成者

   st_type

      ファイルタイプ

   On Windows systems, the following attributes are also available:

   st_file_attributes

      Windows file attributes: "dwFileAttributes" member of the
      "BY_HANDLE_FILE_INFORMATION" structure returned by
      "GetFileInformationByHandle()". See the "FILE_ATTRIBUTE_*
      <stat.FILE_ATTRIBUTE_ARCHIVE>" constants in the "stat" module.

      Added in version 3.5.

   st_reparse_tag

      When "st_file_attributes" has the "FILE_ATTRIBUTE_REPARSE_POINT"
      set, this field contains the tag identifying the type of reparse
      point. See the "IO_REPARSE_TAG_*" constants in the "stat"
      module.

   The standard module "stat" defines functions and constants that are
   useful for extracting information from a "stat" structure. (On
   Windows, some items are filled with dummy values.)

   For backward compatibility, a "stat_result" instance is also
   accessible as a tuple of at least 10 integers giving the most
   important (and portable) members of the "stat" structure, in the
   order "st_mode", "st_ino", "st_dev", "st_nlink", "st_uid",
   "st_gid", "st_size", "st_atime", "st_mtime", "st_ctime". More items
   may be added at the end by some implementations. For compatibility
   with older Python versions, accessing "stat_result" as a tuple
   always returns integers.

   バージョン 3.5 で変更: Windows now returns the file index as
   "st_ino" when available.

   バージョン 3.7 で変更: Added the "st_fstype" member to
   Solaris/derivatives.

   バージョン 3.8 で変更: Added the "st_reparse_tag" member on
   Windows.

   バージョン 3.8 で変更: On Windows, the "st_mode" member now
   identifies special files as "S_IFCHR", "S_IFIFO" or "S_IFBLK" as
   appropriate.

   バージョン 3.12 で変更: On Windows, "st_ctime" is deprecated.
   Eventually, it will contain the last metadata change time, for
   consistency with other platforms, but for now still contains
   creation time. Use "st_birthtime" for the creation time.On Windows,
   "st_ino" may now be up to 128 bits, depending on the file system.
   Previously it would not be above 64 bits, and larger file
   identifiers would be arbitrarily packed.On Windows, "st_rdev" no
   longer returns a value. Previously it would contain the same as
   "st_dev", which was incorrect.Added the "st_birthtime" member on
   Windows.

os.statvfs(path)

   Perform a "statvfs()" system call on the given path.  The return
   value is an object whose attributes describe the filesystem on the
   given path, and correspond to the members of the "statvfs"
   structure, namely: "f_bsize", "f_frsize", "f_blocks", "f_bfree",
   "f_bavail", "f_files", "f_ffree", "f_favail", "f_flag",
   "f_namemax", "f_fsid".

   "f_flag" 属性のビットフラグ用に 2 つのモジュールレベル定数が定義さ
   れています: "ST_RDONLY" が設定されるとファイルシステムは読み出し専
   用でマウントされ、"ST_NOSUID" が設定されると setuid/setgid ビットの
   動作は無効になるか、サポートされません。

   GNU/glibc ベースのシステム用に、追加のモジュールレベルの定数が次の
   ように定義されています。 "ST_NODEV" (デバイス特殊ファイルへのアクセ
   スを許可しない) 、  "ST_NOEXEC" (プログラムの実行を許可しない) 、
   "ST_SYNCHRONOUS" (書き込みが一度に同期される) 、"ST_MANDLOCK" (ファ
   イルシステムで強制的なロックを許可する) 、 "ST_WRITE" (ファイル/デ
   ィレクトリ/シンボリックリンクに書き込む) 、 "ST_APPEND" (追記のみの
   ファイル) 、"ST_IMMUTABLE" (変更不能なファイル) 、 "ST_NOATIME" (ア
   クセス時刻を更新しない) 、"ST_NODIRATIME" (ディレクトリアクセス時刻
   を更新しない) 、"ST_RELATIME" (mtime/ctimeに対して相対的に atime を
   更新する)。

   この関数は ファイル記述子の指定 をサポートしています。

   Availability: Unix.

   バージョン 3.2 で変更: 定数 "ST_RDONLY" および "ST_NOSUID" が追加さ
   れました。

   バージョン 3.3 で変更: *path* へのオープン・ファイル記述子の指定を
   サポートしました。

   バージョン 3.4 で変更: "ST_NODEV", "ST_NOEXEC", "ST_SYNCHRONOUS",
   "ST_MANDLOCK", "ST_WRITE", "ST_APPEND", "ST_IMMUTABLE",
   "ST_NOATIME", "ST_NODIRATIME", "ST_RELATIME" 定数が追加されました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

   バージョン 3.7 で変更: Added the "f_fsid" attribute.

os.supports_dir_fd

   A "set" object indicating which functions in the "os" module accept
   an open file descriptor for their *dir_fd* parameter. Different
   platforms provide different features, and the underlying
   functionality Python uses to implement the *dir_fd* parameter is
   not available on all platforms Python supports.  For consistency's
   sake, functions that may support *dir_fd* always allow specifying
   the parameter, but will throw an exception if the functionality is
   used when it's not locally available. (Specifying "None" for
   *dir_fd* is always supported on all platforms.)

   To check whether a particular function accepts an open file
   descriptor for its *dir_fd* parameter, use the "in" operator on
   "supports_dir_fd". As an example, this expression evaluates to
   "True" if "os.stat()" accepts open file descriptors for *dir_fd* on
   the local platform:

      os.stat in os.supports_dir_fd

   現在 *dir_fd* 引数は Unix プラットフォームでのみ動作します。Windows
   で動作する関数はありません。

   Added in version 3.3.

os.supports_effective_ids

   A "set" object indicating whether "os.access()" permits specifying
   "True" for its *effective_ids* parameter on the local platform.
   (Specifying "False" for *effective_ids* is always supported on all
   platforms.)  If the local platform supports it, the collection will
   contain "os.access()"; otherwise it will be empty.

   This expression evaluates to "True" if "os.access()" supports
   "effective_ids=True" on the local platform:

      os.access in os.supports_effective_ids

   現在 *effective_ids* は Unix プラットフォームでのみサポートされてい
   ます。Windows では動作しません。

   Added in version 3.3.

os.supports_fd

   A "set" object indicating which functions in the "os" module permit
   specifying their *path* parameter as an open file descriptor on the
   local platform.  Different platforms provide different features,
   and the underlying functionality Python uses to accept open file
   descriptors as *path* arguments is not available on all platforms
   Python supports.

   To determine whether a particular function permits specifying an
   open file descriptor for its *path* parameter, use the "in"
   operator on "supports_fd". As an example, this expression evaluates
   to "True" if "os.chdir()" accepts open file descriptors for *path*
   on your local platform:

      os.chdir in os.supports_fd

   Added in version 3.3.

os.supports_follow_symlinks

   A "set" object indicating which functions in the "os" module accept
   "False" for their *follow_symlinks* parameter on the local
   platform. Different platforms provide different features, and the
   underlying functionality Python uses to implement *follow_symlinks*
   is not available on all platforms Python supports.  For
   consistency's sake, functions that may support *follow_symlinks*
   always allow specifying the parameter, but will throw an exception
   if the functionality is used when it's not locally available.
   (Specifying "True" for *follow_symlinks* is always supported on all
   platforms.)

   To check whether a particular function accepts "False" for its
   *follow_symlinks* parameter, use the "in" operator on
   "supports_follow_symlinks".  As an example, this expression
   evaluates to "True" if you may specify "follow_symlinks=False" when
   calling "os.stat()" on the local platform:

      os.stat in os.supports_follow_symlinks

   Added in version 3.3.

os.symlink(src, dst, target_is_directory=False, *, dir_fd=None)

   *src* を指し示すシンボリックリンク *dst* を作成します。

   The *src* parameter refers to the target of the link (the file or
   directory being linked to), and *dst* is the name of the link being
   created.

   Windows では、シンボリックリンクはファイルかディレクトリのどちらか
   を表しますが、ターゲットに合わせて動的に変化することはありません。
   ターゲットが存在する場合、シンボリックリンクの種類は対象に合わせて
   作成されます。ターゲットが存在せず *target_is_directory* に "True"
   が設定された場合、シンボリックリンクはディレクトリのリンクとして作
   成され、"False" に設定された場合 (デフォルト) はファイルのリンクに
   なります。Windows 以外のプラットフォームでは *target_is_directory*
   は無視されます。

   この関数は ディレクトリ記述子への相対パス をサポートしています。

   注釈:

     On newer versions of Windows 10, unprivileged accounts can create
     symlinks if Developer Mode is enabled. When Developer Mode is not
     available/enabled, the *SeCreateSymbolicLinkPrivilege* privilege
     is required, or the process must be run as an administrator.この
     関数が特権を持たないユーザーに呼び出されると、"OSError" が送出さ
     れます。

   引数 "src", "dst", "dir_fd" を指定して 監査イベント "os.symlink" を
   送出します。

   Availability: Unix, Windows.

   The function is limited on WASI, see WebAssembly プラットフォーム
   for more information.

   バージョン 3.2 で変更: Windows 6.0 (Vista) のシンボリックリンクをサ
   ポートしました。

   バージョン 3.3 で変更: Added the *dir_fd* parameter, and now allow
   *target_is_directory* on non-Windows platforms.

   バージョン 3.6 で変更: *src* と *dst* が *path-like object* を受け
   付けるようになりました。

   バージョン 3.8 で変更: Added support for unelevated symlinks on
   Windows with Developer Mode.

os.sync()

   ディスクキャッシュのディスクへの書き出しを強制します。

   Availability: Unix.

   Added in version 3.3.

os.truncate(path, length)

   *path* に対応するファイルを、サイズが最大で *length* バイトになるよ
   う切り詰めます。

   この関数は ファイル記述子の指定 をサポートしています。

   引数 "path", "length" を指定して 監査イベント "os.truncate" を送出
   します。

   Availability: Unix, Windows.

   Added in version 3.3.

   バージョン 3.5 で変更: Windows サポートを追加しました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.unlink(path, *, dir_fd=None)

   ファイル *path* を削除します。意味上は "remove()" と等価です。
   "unlink" の名前は伝統的な Unix の関数名です。詳細は "remove()" のド
   キュメントを参照してください。

   引数 "path", "dir_fd" を指定して 監査イベント "os.remove" を送出し
   ます。

   バージョン 3.3 で変更: 引数 *dir_fd* を追加しました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.utime(path, times=None, *, [ns, ]dir_fd=None, follow_symlinks=True)

   *path* で指定されたファイルに最終アクセス時刻および最終修正時刻を設
   定します。

   "utime()" は 2 つの任意引数 *times* と *ns* をとります。これらは
   *path* に設定する時刻を指定し、以下のように使用されます:

   * *ns* を指定する場合、ナノ秒を表す整数値をメンバーとして使用して、
     "(atime_ns, mtime_ns)" の形式の 2 要素タプルを指定する必要があり
     ます。

   * *times* が "None" ではない場合、"(atime, mtime)" の形式で各メンバ
     ーは単位を秒で表す整数か浮動小数点値のタプルを指定しなければなり
     ません。

   * *times* が "None" で、 *ns* が指定されていない場合、これは両方の
     時間を現在時刻として "ns=(atime_ns, mtime_ns)" を指定することと等
     価です。

   *times* と *ns* の両方にタプルが指定されるとエラーになります。

   ここで設定した時刻が、後に "stat()" の呼び出し時正確に返されない場
   合があります。これはオペレーティングシステムが記録するアクセスおよ
   び修正時刻の精度に依存しています; "stat()" を参照してください。正確
   な時刻を保持する最善の方法は、"utime()" で *ns* 引数を指定し、
   "os.stat()" の返り値オブジェクトから *st_atime_ns* および
   *st_mtime_ns* フィールドを使用することです。

   この関数は ファイル記述子の指定 、 ディレクトリ記述子への相対パス
   、および シンボリックリンクをたどらない をサポートしています。

   引数 "path", "times", "ns", "dir_fd" を指定して 監査イベント
   "os.utime" を送出します。

   バージョン 3.3 で変更: *path* にオープンしているファイル記述子の指
   定のサポート、および引数 *dir_fd*, *follow_symlinks*, *ns* を追加し
   ました。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.walk(top, topdown=True, onerror=None, followlinks=False)

   ディレクトリツリー以下のファイル名を、ツリーをトップダウンもしくは
   ボトムアップに走査することで作成します。ディレクトリ *top* を根に持
   つディレクトリツリーに含まれる、各ディレクトリ (*top* 自身を含む )
   ごとに、タプル "(dirpath, dirnames, filenames)" を yield します。

   *dirpath* is a string, the path to the directory.  *dirnames* is a
   list of the names of the subdirectories in *dirpath* (including
   symlinks to directories, and excluding "'.'" and "'..'").
   *filenames* is a list of the names of the non-directory files in
   *dirpath*. Note that the names in the lists contain no path
   components.  To get a full path (which begins with *top*) to a file
   or directory in *dirpath*, do "os.path.join(dirpath, name)".
   Whether or not the lists are sorted depends on the file system.  If
   a file is removed from or added to the *dirpath* directory during
   generating the lists, whether a name for that file be included is
   unspecified.

   オプション引数 *topdown* が "True" であるか、指定されなかった場合、
   各ディレクトリからタプルを生成した後で、サブディレクトリからタプル
   を生成します。( ディレクトリはトップダウンで生成 ) 。 *topdown* が
   "False" の場合、ディレクトリに対応するタプルは、そのディレクトリ以
   下の全てのサブディレクトリに対応するタプルの後で ( ボトムアップで )
   生成されます。 *topdown* の値によらず、サブディレクトリのリストは、
   ディレクトリとそのサブディレクトリのタプルを生成する前に取り出され
   ます。

   *topdown* が "True" のとき、呼び出し側は *dirnames* リストを、イン
   プレースで ( たとえば、 "del" やスライスを使った代入で ) 変更でき、
   "walk()" は *dirnames* に残っているサブディレクトリ内のみを再帰しま
   す。これにより、検索を省略したり、特定の訪問順序を強制したり、呼び
   出し側が "walk()" を再開する前に、呼び出し側が作った、または名前を
   変更したディレクトリを、 "walk()" に知らせたりすることができます。
   *topdown* が "False" のときに *dirnames* を変更しても効果はありませ
   ん。ボトムアップモードでは *dirpath* 自身が生成される前に
   *dirnames* 内のディレクトリの情報が生成されるからです。

   デフォルトでは、 "scandir()" 呼び出しからのエラーは無視されます。オ
   プション引数の *onerror* を指定する場合は関数でなければなりません ;
   この関数は単一の引数として "OSError" インスタンスを伴って呼び出され
   ます。この関数でエラーを報告して走査を継続したり、例外を送出して走
   査を中止したりできます。ファイル名は例外オブジェクトの "filename"
   属性として利用できます。

   デフォルトでは、 "walk()" はディレクトリへのシンボリックリンクをた
   どりません。 *followlinks* に "True" を指定すると、ディレクトリへの
   シンボリックリンクをサポートしているシステムでは、シンボリックリン
   クの指しているディレクトリを走査します。

   注釈:

     *followlinks* に "True" を指定すると、シンボリックリンクが親ディ
     レクトリを指していた場合に、無限ループになることに注意してくださ
     い。 "walk()" はすでにたどったディレクトリを管理したりはしません
     。

   注釈:

     相対パスを渡した場合、 "walk()" が再開されるまでの間に現在の作業
     ディレクトリを変更しないでください。 "walk()" はカレントディレク
     トリを変更しませんし、呼び出し側もカレントディレクトリを変更しな
     いと仮定しています。

   This example displays the number of bytes taken by non-directory
   files in each directory under the starting directory, except that
   it doesn't look under any "__pycache__" subdirectory:

      import os
      from os.path import join, getsize
      for root, dirs, files in os.walk('python/Lib/xml'):
          print(root, "consumes", end=" ")
          print(sum(getsize(join(root, name)) for name in files), end=" ")
          print("bytes in", len(files), "non-directory files")
          if '__pycache__' in dirs:
              dirs.remove('__pycache__')  # don't visit __pycache__ directories

   次の例 ("shutil.rmtree()" の単純な実装) では、ツリーをボトムアップ
   で走査することが不可欠になります; "rmdir()" はディレクトリが空にな
   るまで削除を許さないからです:

      # Delete everything reachable from the directory named in "top",
      # assuming there are no symbolic links.
      # CAUTION:  This is dangerous!  For example, if top == '/', it
      # could delete all your disk files.
      import os
      for root, dirs, files in os.walk(top, topdown=False):
          for name in files:
              os.remove(os.path.join(root, name))
          for name in dirs:
              os.rmdir(os.path.join(root, name))
      os.rmdir(top)

   引数 "top", "topdown", "onerror", "followlinks" を指定して 監査イベ
   ント "os.walk" を送出します。

   バージョン 3.5 で変更: この関数は、今では "os.listdir()" ではなく
   "os.scandir()" を呼び出します。これにより、 "os.stat()" の呼び出し
   回数を削減でき、動作が高速化します。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.fwalk(top='.', topdown=True, onerror=None, *, follow_symlinks=False, dir_fd=None)

   挙動は "walk()" と同じですが、"dir_fd" をサポートし、タプル
   "(dirpath, dirnames, filenames, dirfd)" を yield します。

   *dirpath*、*dirnames*、および *filenames* は "walk()" の出力と同じ
   で、*dirfd* は *dirpath* を参照するファイル記述子です。

   この関数は常に ディレクトリ記述子への相対パス および シンボリックリ
   ンクをたどらない をサポートしています。ただし、他の関数と異なり、
   "fwalk()" での *follow_symlinks* のデフォルト値は "False" になるこ
   とに注意してください。

   注釈:

     "fwalk()" はファイル記述子を yield するため、それらが有効なのは次
     のイテレートステップまでです。それ以後も保持したい場合は "dup()"
     などを使って複製して使用してください。

   This example displays the number of bytes taken by non-directory
   files in each directory under the starting directory, except that
   it doesn't look under any "__pycache__" subdirectory:

      import os
      for root, dirs, files, rootfd in os.fwalk('python/Lib/xml'):
          print(root, "consumes", end=" ")
          print(sum([os.stat(name, dir_fd=rootfd).st_size for name in files]),
                end=" ")
          print("bytes in", len(files), "non-directory files")
          if '__pycache__' in dirs:
              dirs.remove('__pycache__')  # don't visit __pycache__ directories

   次の例では、ツリーをボトムアップで走査することが不可欠になります ;
   "rmdir()" はディレクトリが空になるまで削除を許さないからです

      # Delete everything reachable from the directory named in "top",
      # assuming there are no symbolic links.
      # CAUTION:  This is dangerous!  For example, if top == '/', it
      # could delete all your disk files.
      import os
      for root, dirs, files, rootfd in os.fwalk(top, topdown=False):
          for name in files:
              os.unlink(name, dir_fd=rootfd)
          for name in dirs:
              os.rmdir(name, dir_fd=rootfd)

   引数 "top", "topdown", "onerror", "follow_symlinks" を指定して 監査
   イベント "os.fwalk" を送出します。

   Availability: Unix.

   Added in version 3.3.

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

   バージョン 3.7 で変更: Added support for "bytes" paths.

os.memfd_create(name[, flags=os.MFD_CLOEXEC])

   Create an anonymous file and return a file descriptor that refers
   to it. *flags* must be one of the "os.MFD_*" constants available on
   the system (or a bitwise ORed combination of them).  By default,
   the new file descriptor is non-inheritable.

   The name supplied in *name* is used as a filename and will be
   displayed as the target of the corresponding symbolic link in the
   directory "/proc/self/fd/". The displayed name is always prefixed
   with "memfd:" and serves only for debugging purposes. Names do not
   affect the behavior of the file descriptor, and as such multiple
   files can have the same name without any side effects.

   Availability: Linux >= 3.17 with glibc >= 2.27.

   Added in version 3.8.

os.MFD_CLOEXEC
os.MFD_ALLOW_SEALING
os.MFD_HUGETLB
os.MFD_HUGE_SHIFT
os.MFD_HUGE_MASK
os.MFD_HUGE_64KB
os.MFD_HUGE_512KB
os.MFD_HUGE_1MB
os.MFD_HUGE_2MB
os.MFD_HUGE_8MB
os.MFD_HUGE_16MB
os.MFD_HUGE_32MB
os.MFD_HUGE_256MB
os.MFD_HUGE_512MB
os.MFD_HUGE_1GB
os.MFD_HUGE_2GB
os.MFD_HUGE_16GB

   These flags can be passed to "memfd_create()".

   Availability: Linux >= 3.17 with glibc >= 2.27

   The "MFD_HUGE*" flags are only available since Linux 4.14.

   Added in version 3.8.

os.eventfd(initval[, flags=os.EFD_CLOEXEC])

   Create and return an event file descriptor. The file descriptors
   supports raw "read()" and "write()" with a buffer size of 8,
   "select()", "poll()" and similar. See man page *eventfd(2)* for
   more information.  By default, the new file descriptor is non-
   inheritable.

   *initval* is the initial value of the event counter. The initial
   value must be a 32 bit unsigned integer. Please note that the
   initial value is limited to a 32 bit unsigned int although the
   event counter is an unsigned 64 bit integer with a maximum value of
   2^64-2.

   *flags* can be constructed from "EFD_CLOEXEC", "EFD_NONBLOCK", and
   "EFD_SEMAPHORE".

   If "EFD_SEMAPHORE" is specified and the event counter is non-zero,
   "eventfd_read()" returns 1 and decrements the counter by one.

   If "EFD_SEMAPHORE" is not specified and the event counter is non-
   zero, "eventfd_read()" returns the current event counter value and
   resets the counter to zero.

   If the event counter is zero and "EFD_NONBLOCK" is not specified,
   "eventfd_read()" blocks.

   "eventfd_write()" increments the event counter. Write blocks if the
   write operation would increment the counter to a value larger than
   2^64-2.

   以下はプログラム例です:

      import os

      # semaphore with start value '1'
      fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFD_CLOEXEC)
      try:
          # acquire semaphore
          v = os.eventfd_read(fd)
          try:
              do_work()
          finally:
              # release semaphore
              os.eventfd_write(fd, v)
      finally:
          os.close(fd)

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.10.

os.eventfd_read(fd)

   Read value from an "eventfd()" file descriptor and return a 64 bit
   unsigned int. The function does not verify that *fd* is an
   "eventfd()".

   Availability: Linux >= 2.6.27

   Added in version 3.10.

os.eventfd_write(fd, value)

   Add value to an "eventfd()" file descriptor. *value* must be a 64
   bit unsigned int. The function does not verify that *fd* is an
   "eventfd()".

   Availability: Linux >= 2.6.27

   Added in version 3.10.

os.EFD_CLOEXEC

   Set close-on-exec flag for new "eventfd()" file descriptor.

   Availability: Linux >= 2.6.27

   Added in version 3.10.

os.EFD_NONBLOCK

   Set "O_NONBLOCK" status flag for new "eventfd()" file descriptor.

   Availability: Linux >= 2.6.27

   Added in version 3.10.

os.EFD_SEMAPHORE

   Provide semaphore-like semantics for reads from an "eventfd()" file
   descriptor. On read the internal counter is decremented by one.

   Availability: Linux >= 2.6.30

   Added in version 3.10.


Timer File Descriptors
----------------------

Added in version 3.13.

These functions provide support for Linux's *timer file descriptor*
API. Naturally, they are all only available on Linux.

os.timerfd_create(clockid, /, *, flags=0)

   Create and return a timer file descriptor (*timerfd*).

   The file descriptor returned by "timerfd_create()" supports:

   * "read()"

   * "select()"

   * "poll()"

   The file descriptor's "read()" method can be called with a buffer
   size of 8. If the timer has already expired one or more times,
   "read()" returns the number of expirations with the host's
   endianness, which may be converted to an "int" by
   "int.from_bytes(x, byteorder=sys.byteorder)".

   "select()" and "poll()" can be used to wait until timer expires and
   the file descriptor is readable.

   *clockid* must be a valid clock ID, as defined in the "time"
   module:

   * "time.CLOCK_REALTIME"

   * "time.CLOCK_MONOTONIC"

   * "time.CLOCK_BOOTTIME" (Since Linux 3.15 for timerfd_create)

   If *clockid* is "time.CLOCK_REALTIME", a settable system-wide real-
   time clock is used. If system clock is changed, timer setting need
   to be updated. To cancel timer when system clock is changed, see
   "TFD_TIMER_CANCEL_ON_SET".

   If *clockid* is "time.CLOCK_MONOTONIC", a non-settable
   monotonically increasing clock is used. Even if the system clock is
   changed, the timer setting will not be affected.

   If *clockid* is "time.CLOCK_BOOTTIME", same as
   "time.CLOCK_MONOTONIC" except it includes any time that the system
   is suspended.

   The file descriptor's behaviour can be modified by specifying a
   *flags* value. Any of the following variables may used, combined
   using bitwise OR (the "|" operator):

   * "TFD_NONBLOCK"

   * "TFD_CLOEXEC"

   If "TFD_NONBLOCK" is not set as a flag, "read()" blocks until the
   timer expires. If it is set as a flag, "read()" doesn't block, but
   If there hasn't been an expiration since the last call to read,
   "read()" raises "OSError" with "errno" is set to "errno.EAGAIN".

   "TFD_CLOEXEC" is always set by Python automatically.

   The file descriptor must be closed with "os.close()" when it is no
   longer needed, or else the file descriptor will be leaked.

   参考: The *timerfd_create(2)* man page.

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.13.

os.timerfd_settime(fd, /, *, flags=flags, initial=0.0, interval=0.0)

   Alter a timer file descriptor's internal timer. This function
   operates the same interval timer as "timerfd_settime_ns()".

   *fd* must be a valid timer file descriptor.

   The timer's behaviour can be modified by specifying a *flags*
   value. Any of the following variables may used, combined using
   bitwise OR (the "|" operator):

   * "TFD_TIMER_ABSTIME"

   * "TFD_TIMER_CANCEL_ON_SET"

   The timer is disabled by setting *initial* to zero ("0"). If
   *initial* is equal to or greater than zero, the timer is enabled.
   If *initial* is less than zero, it raises an "OSError" exception
   with "errno" set to "errno.EINVAL"

   By default the timer will fire when *initial* seconds have elapsed.
   (If *initial* is zero, timer will fire immediately.)

   However, if the "TFD_TIMER_ABSTIME" flag is set, the timer will
   fire when the timer's clock (set by *clockid* in
   "timerfd_create()") reaches *initial* seconds.

   The timer's interval is set by the *interval* "float". If
   *interval* is zero, the timer only fires once, on the initial
   expiration. If *interval* is greater than zero, the timer fires
   every time *interval* seconds have elapsed since the previous
   expiration. If *interval* is less than zero, it raises "OSError"
   with "errno" set to "errno.EINVAL"

   If the "TFD_TIMER_CANCEL_ON_SET" flag is set along with
   "TFD_TIMER_ABSTIME" and the clock for this timer is
   "time.CLOCK_REALTIME", the timer is marked as cancelable if the
   real-time clock is changed discontinuously. Reading the descriptor
   is aborted with the error ECANCELED.

   Linux manages system clock as UTC. A daylight-savings time
   transition is done by changing time offset only and doesn't cause
   discontinuous system clock change.

   Discontinuous system clock change will be caused by the following
   events:

   * "settimeofday"

   * "clock_settime"

   * set the system date and time by "date" command

   Return a two-item tuple of ("next_expiration", "interval") from the
   previous timer state, before this function executed.

   参考:

     *timerfd_create(2)*, *timerfd_settime(2)*, *settimeofday(2)*,
     *clock_settime(2)*, and *date(1)*.

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.13.

os.timerfd_settime_ns(fd, /, *, flags=0, initial=0, interval=0)

   Similar to "timerfd_settime()", but use time as nanoseconds. This
   function operates the same interval timer as "timerfd_settime()".

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.13.

os.timerfd_gettime(fd, /)

   Return a two-item tuple of floats ("next_expiration", "interval").

   "next_expiration" denotes the relative time until next the timer
   next fires, regardless of if the "TFD_TIMER_ABSTIME" flag is set.

   "interval" denotes the timer's interval. If zero, the timer will
   only fire once, after "next_expiration" seconds have elapsed.

   参考: *timerfd_gettime(2)*

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.13.

os.timerfd_gettime_ns(fd, /)

   Similar to "timerfd_gettime()", but return time as nanoseconds.

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.13.

os.TFD_NONBLOCK

   A flag for the "timerfd_create()" function, which sets the
   "O_NONBLOCK" status flag for the new timer file descriptor. If
   "TFD_NONBLOCK" is not set as a flag, "read()" blocks.

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.13.

os.TFD_CLOEXEC

   A flag for the "timerfd_create()" function, If "TFD_CLOEXEC" is set
   as a flag, set close-on-exec flag for new file descriptor.

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.13.

os.TFD_TIMER_ABSTIME

   A flag for the "timerfd_settime()" and "timerfd_settime_ns()"
   functions. If this flag is set, *initial* is interpreted as an
   absolute value on the timer's clock (in UTC seconds or nanoseconds
   since the Unix Epoch).

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.13.

os.TFD_TIMER_CANCEL_ON_SET

   A flag for the "timerfd_settime()" and "timerfd_settime_ns()"
   functions along with "TFD_TIMER_ABSTIME". The timer is cancelled
   when the time of the underlying clock changes discontinuously.

   Availability: Linux >= 2.6.27 with glibc >= 2.8

   Added in version 3.13.


Linux 拡張属性
--------------

Added in version 3.3.

以下の関数はすべて Linux でのみ使用可能です。

os.getxattr(path, attribute, *, follow_symlinks=True)

   Return the value of the extended filesystem attribute *attribute*
   for *path*. *attribute* can be bytes or str (directly or indirectly
   through the "PathLike" interface). If it is str, it is encoded with
   the filesystem encoding.

   この関数は ファイル記述子の指定 および シンボリックリンクをたどらな
   い をサポートしています。

   引数 "path", "attribute" を指定して 監査イベント "os.getxattr" を送
   出します。

   バージョン 3.6 で変更: *path* と *attribute* が *path-like object*
   を受け付けるようになりました。

os.listxattr(path=None, *, follow_symlinks=True)

   *path* の拡張ファイルシステム属性のリストを返します。リスト内の属性
   はファイルシステムのエンコーディングでデコードされた文字列で表され
   ます。*path* が "None" の場合、"listxattr()" はカレントディレクトリ
   を調べます。

   この関数は ファイル記述子の指定 および シンボリックリンクをたどらな
   い をサポートしています。

   引数 "path" を指定して 監査イベント "os.listxattr" を送出します。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os.removexattr(path, attribute, *, follow_symlinks=True)

   Removes the extended filesystem attribute *attribute* from *path*.
   *attribute* should be bytes or str (directly or indirectly through
   the "PathLike" interface). If it is a string, it is encoded with
   the *filesystem encoding and error handler*.

   この関数は ファイル記述子の指定 および シンボリックリンクをたどらな
   い をサポートしています。

   引数 "path", "attribute" を指定して 監査イベント "os.removexattr"
   を送出します。

   バージョン 3.6 で変更: *path* と *attribute* が *path-like object*
   を受け付けるようになりました。

os.setxattr(path, attribute, value, flags=0, *, follow_symlinks=True)

   Set the extended filesystem attribute *attribute* on *path* to
   *value*. *attribute* must be a bytes or str with no embedded NULs
   (directly or indirectly through the "PathLike" interface). If it is
   a str, it is encoded with the *filesystem encoding and error
   handler*.  *flags* may be "XATTR_REPLACE" or "XATTR_CREATE". If
   "XATTR_REPLACE" is given and the attribute does not exist,
   "ENODATA" will be raised. If "XATTR_CREATE" is given and the
   attribute already exists, the attribute will not be created and
   "EEXISTS" will be raised.

   この関数は ファイル記述子の指定 および シンボリックリンクをたどらな
   い をサポートしています。

   注釈:

     Linux カーネル 2.6.39 以前では、バグのため一部のファイルシステム
     で引数 flags が無視されます。

   引数 "path", "attribute", "value", "flags" を指定して 監査イベント
   "os.setxattr" を送出します。

   バージョン 3.6 で変更: *path* と *attribute* が *path-like object*
   を受け付けるようになりました。

os.XATTR_SIZE_MAX

   拡張属性の値にできる最大サイズです。現在、Linux では 64 キロバイト
   です。

os.XATTR_CREATE

   "setxattr()" の引数 flags に指定できる値です。その操作で属性を作成
   しなければならないことを意味します。

os.XATTR_REPLACE

   "setxattr()" の引数 flags に指定できる値です。その操作で既存の属性
   を置き換えなければならないことを意味します。


プロセス管理
============

以下の関数はプロセスの生成や管理に利用できます。

さまざまな "exec*" 関数は、プロセス内にロードされる新しいプログラムに
与えるための、引数のリストを取ります。どの関数の場合でも、新しいプログ
ラムに渡されるリストの最初の引数は、ユーザがコマンドラインで入力する引
数ではなく、そのプログラム自体の名前です。 C プログラマならば、プログ
ラムの "main()" に渡される "argv[0]" だと考えれば良いでしょう。たとえ
ば、 "os.execv('/bin/echo', ['foo', 'bar'])" が標準出力に出力するのは
"bar" だけで、 "foo" は無視されたかのように見えることになります。

os.abort()

   "SIGABRT" シグナルを現在のプロセスに対して生成します。 Unix では、
   デフォルトの動作はコアダンプの生成です ; Windows では、プロセスは即
   座に終了コード "3" を返します。この関数の呼び出しは
   "signal.signal()" を使って "SIGABRT" に対し登録された Python シグナ
   ルハンドラーを呼び出さないことに注意してください。

os.add_dll_directory(path)

   Add a path to the DLL search path.

   This search path is used when resolving dependencies for imported
   extension modules (the module itself is resolved through
   "sys.path"), and also by "ctypes".

   Remove the directory by calling **close()** on the returned object
   or using it in a "with" statement.

   See the Microsoft documentation for more information about how DLLs
   are loaded.

   引数 "path" を指定して 監査イベント "os.add_dll_directory" を送出し
   ます。

   Availability: Windows.

   Added in version 3.8: Previous versions of CPython would resolve
   DLLs using the default behavior for the current process. This led
   to inconsistencies, such as only sometimes searching "PATH" or the
   current working directory, and OS functions such as
   "AddDllDirectory" having no effect.In 3.8, the two primary ways
   DLLs are loaded now explicitly override the process-wide behavior
   to ensure consistency. See the porting notes for information on
   updating libraries.

os.execl(path, arg0, arg1, ...)
os.execle(path, arg0, arg1, ..., env)
os.execlp(file, arg0, arg1, ...)
os.execlpe(file, arg0, arg1, ..., env)
os.execv(path, args)
os.execve(path, args, env)
os.execvp(file, args)
os.execvpe(file, args, env)

   これらの関数はすべて、現在のプロセスを置き換える形で新たなプログラ
   ムを実行します ; 現在のプロセスは返り値を返しません。 Unix では、新
   たに実行される実行コードは現在のプロセス内に読み込まれ、呼び出し側
   と同じプロセス ID を持つことになります。エラーは "OSError" 例外とし
   て報告されます。

   現在のプロセスは瞬時に置き換えられます。開かれているファイルオブジ
   ェクトやファイル記述子はフラッシュされません。そのため、バッファ内
   にデータが残っているかもしれない場合、 "exec*" 関数を実行する前に
   "sys.stdout.flush()" か "os.fsync()" を利用してバッファをフラッシュ
   しておく必要があります。

   The "l" and "v" variants of the "exec*" functions differ in how
   command-line arguments are passed.  The "l" variants are perhaps
   the easiest to work with if the number of parameters is fixed when
   the code is written; the individual parameters simply become
   additional parameters to the "execl*()" functions.  The "v"
   variants are good when the number of parameters is variable, with
   the arguments being passed in a list or tuple as the *args*
   parameter.  In either case, the arguments to the child process
   should start with the name of the command being run, but this is
   not enforced.

   The variants which include a "p" near the end ("execlp()",
   "execlpe()", "execvp()", and "execvpe()") will use the "PATH"
   environment variable to locate the program *file*.  When the
   environment is being replaced (using one of the "exec*e" variants,
   discussed in the next paragraph), the new environment is used as
   the source of the "PATH" variable. The other variants, "execl()",
   "execle()", "execv()", and "execve()", will not use the "PATH"
   variable to locate the executable; *path* must contain an
   appropriate absolute or relative path. Relative paths must include
   at least one slash, even on Windows, as plain names will not be
   resolved.

   "execle()" 、 "execlpe()" 、 "execve()" 、および "execvpe()" (すべ
   て末尾に "e" がついています) では、 *env* 引数は新たなプロセスで利
   用される環境変数を定義するためのマップ型でなくてはなりません ( 現在
   のプロセスの環境変数の代わりに利用されます ); "execl()" 、
   "execlp()" 、 "execv()" 、および "execvp()" では、すべて新たなプロ
   セスは現在のプロセスの環境を引き継ぎます。

   一部のプラットフォームの "execve()" では、*path* はオープンしている
   ファイル記述子で指定することもできます。この機能をサポートしていな
   いプラットフォームもあります; "os.supports_fd" を使うことで利用可能
   かどうか調べることができます。利用できない場合、
   "NotImplementedError" が送出されます。

   引数 "path", "args", "env" を指定して 監査イベント "os.exec" を送出
   します。

   Availability: Unix, Windows, not WASI, not Android, not iOS.

   バージョン 3.3 で変更: Added support for specifying *path* as an
   open file descriptor for "execve()".

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

os._exit(n)

   終了ステータス *n* でプロセスを終了します。この時クリーンアップハン
   ドラーの呼び出しや、標準入出力バッファのフラッシュなどは行いません
   。

   注釈:

     The standard way to exit is "sys.exit(n)".  "_exit()" should
     normally only be used in the child process after a "fork()".

以下の終了コードは必須ではありませんが "_exit()" で使うことができます
。一般に、メールサーバーの外部コマンド配送プログラムのような、 Python
で書かれたシステムプログラムに使います。

注釈:

  いくつかのバリエーションがあって、これらのすべてがすべての Unix プラ
  ットフォームで使えるわけではありません。以下の定数は下層のプラットフ
  ォームで定義されていれば定義されます。

os.EX_OK

   Exit code that means no error occurred. May be taken from the
   defined value of "EXIT_SUCCESS" on some platforms. Generally has a
   value of zero.

   Availability: Unix, Windows.

os.EX_USAGE

   誤った個数の引数が渡された時など、コマンドが間違って使われたことを
   表す終了コード。

   Availability: Unix, not WASI.

os.EX_DATAERR

   入力データが誤っていたことを表す終了コード。

   Availability: Unix, not WASI.

os.EX_NOINPUT

   入力ファイルが存在しなかった、または、読み込み不可だったことを表す
   終了コード。

   Availability: Unix, not WASI.

os.EX_NOUSER

   指定されたユーザーが存在しなかったことを表す終了コード。

   Availability: Unix, not WASI.

os.EX_NOHOST

   指定されたホストが存在しなかったことを表す終了コード。

   Availability: Unix, not WASI.

os.EX_UNAVAILABLE

   要求されたサービスが利用できないことを表す終了コード。

   Availability: Unix, not WASI.

os.EX_SOFTWARE

   内部ソフトウェアエラーが検出されたことを表す終了コード。

   Availability: Unix, not WASI.

os.EX_OSERR

   fork できない、 pipe の作成ができないなど、オペレーティングシステム
   のエラーが検出されたことを表す終了コード。

   Availability: Unix, not WASI.

os.EX_OSFILE

   システムファイルが存在しなかった、開けなかった、あるいはその他のエ
   ラーが起きたことを表す終了コード。

   Availability: Unix, not WASI.

os.EX_CANTCREAT

   ユーザーには作成できない出力ファイルを指定したことを表す終了コード
   。

   Availability: Unix, not WASI.

os.EX_IOERR

   ファイルの I/O を行っている途中にエラーが発生した時の終了コード。

   Availability: Unix, not WASI.

os.EX_TEMPFAIL

   一時的な失敗が発生したことを表す終了コード。これは、再試行可能な操
   作の途中に、ネットワークに接続できないというような、実際にはエラー
   ではないかも知れないことを意味します。

   Availability: Unix, not WASI.

os.EX_PROTOCOL

   プロトコル交換が不正、不適切、または理解不能なことを表す終了コード
   。

   Availability: Unix, not WASI.

os.EX_NOPERM

   操作を行うために十分な許可がなかった（ファイルシステムの問題を除く
   ）ことを表す終了コード。

   Availability: Unix, not WASI.

os.EX_CONFIG

   設定エラーが起こったことを表す終了コード。

   Availability: Unix, not WASI.

os.EX_NOTFOUND

   "an entry was not found" のようなことを表す終了コード。

   Availability: Unix, not WASI.

os.fork()

   子プロセスを fork します。子プロセスでは "0" が返り、親プロセスでは
   子プロセスの id が返ります。エラーが発生した場合は、 "OSError" を送
   出します。

   FreeBSD 6.3 以下、Cygwinを含む一部のプラットフォームにおいて、
   "fork()" をスレッド内から利用した場合に既知の問題があることに注意し
   てください。

   引数無しで 監査イベント "os.fork" を送出します。

   警告:

     If you use TLS sockets in an application calling "fork()", see
     the warning in the "ssl" documentation.

   警告:

     On macOS the use of this function is unsafe when mixed with using
     higher-level system APIs, and that includes using
     "urllib.request".

   バージョン 3.8 で変更: Calling "fork()" in a subinterpreter is no
   longer supported ("RuntimeError" is raised).

   バージョン 3.12 で変更: If Python is able to detect that your
   process has multiple threads, "os.fork()" now raises a
   "DeprecationWarning".We chose to surface this as a warning, when
   detectable, to better inform developers of a design problem that
   the POSIX platform specifically notes as not supported. Even in
   code that *appears* to work, it has never been safe to mix
   threading with "os.fork()" on POSIX platforms. The CPython runtime
   itself has always made API calls that are not safe for use in the
   child process when threads existed in the parent (such as "malloc"
   and "free").Users of macOS or users of libc or malloc
   implementations other than those typically found in glibc to date
   are among those already more likely to experience deadlocks running
   such code.See this discussion on fork being incompatible with
   threads for technical details of why we're surfacing this
   longstanding platform compatibility problem to developers.

   Availability: POSIX, not WASI, not Android, not iOS.

os.forkpty()

   子プロセスを fork します。この時新しい擬似端末を子プロセスの制御端
   末として使います。親プロセスでは "(pid, fd)" からなるペアが返り、
   *fd* は擬似端末のマスター側のファイル記述子となります。可搬性のある
   アプローチを取るには、 "pty" モジュールを利用してください。エラーが
   発生した場合は、 "OSError" を送出します。

   引数無しで 監査イベント "os.forkpty" を送出します。

   警告:

     On macOS the use of this function is unsafe when mixed with using
     higher-level system APIs, and that includes using
     "urllib.request".

   バージョン 3.8 で変更: Calling "forkpty()" in a subinterpreter is
   no longer supported ("RuntimeError" is raised).

   バージョン 3.12 で変更: If Python is able to detect that your
   process has multiple threads, this now raises a
   "DeprecationWarning". See the longer explanation on "os.fork()".

   Availability: Unix, not WASI, not Android, not iOS.

os.kill(pid, sig, /)

   プロセス *pid* にシグナル *sig* を送ります。ホストプラットフォーム
   で利用可能なシグナルを特定する定数は "signal" モジュールで定義され
   ています。

   Windows: The "signal.CTRL_C_EVENT" and "signal.CTRL_BREAK_EVENT"
   signals are special signals which can only be sent to console
   processes which share a common console window, e.g., some
   subprocesses. Any other value for *sig* will cause the process to
   be unconditionally killed by the TerminateProcess API, and the exit
   code will be set to *sig*.

   "signal.pthread_kill()" も参照してください。

   引数 "pid", "sig" を指定して 監査イベント "os.kill" を送出します。

   Availability: Unix, Windows, not WASI, not iOS.

   バージョン 3.2 で変更: Windows サポートを追加しました。

os.killpg(pgid, sig, /)

   プロセスグループ *pgid* にシグナル *sig* を送ります。

   引数 "pgid", "sig" を指定して 監査イベント "os.killpg" を送出します
   。

   Availability: Unix, not WASI, not iOS.

os.nice(increment, /)

   プロセスの "nice 値 " に *increment* を加えます。新たな nice 値を返
   します。

   Availability: Unix, not WASI.

os.pidfd_open(pid, flags=0)

   Return a file descriptor referring to the process *pid* with
   *flags* set. This descriptor can be used to perform process
   management without races and signals.

   See the *pidfd_open(2)* man page for more details.

   Availability: Linux >= 5.3, Android >= "build-time" API level 31

   Added in version 3.9.

   os.PIDFD_NONBLOCK

      This flag indicates that the file descriptor will be non-
      blocking. If the process referred to by the file descriptor has
      not yet terminated, then an attempt to wait on the file
      descriptor using *waitid(2)* will immediately return the error
      "EAGAIN" rather than blocking.

   Availability: Linux >= 5.10

   Added in version 3.12.

os.plock(op, /)

   プログラムのセグメントをメモリ内にロックします。 *op*
   ("<sys/lock.h>" で定義されています ) にはどのセグメントをロックする
   かを指定します。

   Availability: Unix, not WASI, not iOS.

os.popen(cmd, mode='r', buffering=-1)

   コマンド *cmd* への、または *cmd* からのパイプ入出力を開きます。戻
   り値はパイプに接続されている開かれたファイルオブジェクトで、 *mode*
   が "'r'" (デフォルト) または "'w'" かによって読み出しまたは書き込み
   を行うことができます。引数 *bufsize* は、組み込み関数 "open()" にお
   ける対応する引数と同じ意味を持ちます。 返されるファイルオブジェクト
   は、バイトではなくテキスト文字列を読み書きします。

   "close" メソッドは、サブプロセスが正常に終了した場合は "None" を返
   し、エラーが発生した場合にはサブプロセスの返りコードを返します。
   POSIX システムでは、返りコードが正の場合、そのコードは1バイト左にシ
   フトしてプロセスが終了したことを示します。返りコードが負の場合、プ
   ロセスは返りコードの符号を変えた信号により終了します 。 (例えば、サ
   ブプロセスが kill された場合、返り値は "- signal.SIGKILL" となる場
   合があります。) Windows システムでは、返り値には子プロセスからの符
   号のついた整数の返りコードを含まれます。

   On Unix, "waitstatus_to_exitcode()" can be used to convert the
   "close" method result (exit status) into an exit code if it is not
   "None". On Windows, the "close" method result is directly the exit
   code (or "None").

   これは、"subprocess.Popen" を使用して実装されています。サブプロセス
   を管理し、サブプロセスと通信を行うためのより強力な方法については、
   クラスのドキュメンテーションを参照してください。

   Availability: not WASI, not Android, not iOS.

   注釈:

     The Python UTF-8 Mode affects encodings used for *cmd* and pipe
     contents."popen()" is a simple wrapper around "subprocess.Popen".
     Use "subprocess.Popen" or "subprocess.run()" to control options
     like encodings.

   バージョン 3.14 で非推奨: The function is *soft deprecated* and
   should no longer be used to write new code. The "subprocess" module
   is recommended instead.

os.posix_spawn(path, argv, env, *, file_actions=None, setpgroup=None, resetids=False, setsid=False, setsigmask=(), setsigdef=(), scheduler=None)

   Wraps the "posix_spawn()" C library API for use from Python.

   大部分のユーザーは "posix_spawn()" ではなく、 "subprocess.run()" を
   使うべきです。

   The positional-only arguments *path*, *args*, and *env* are similar
   to "execve()". *env* is allowed to be "None", in which case current
   process' environment is used.

   *path* には実行ファイルへのパスを指定します。 *path* はディレクトリ
   を含む形（実行ファイルへの絶対パスまたは相対パス）で指定する必要が
   あります。実行ファイル名のみを指定したい場合は "posix_spawnp()" を
   使ってください。

   *file_actions* 引数はCライブラリ実装の "fork()" と "exec()" の間で
   子プロセスが持つファイルデスクリプタに対して行うアクションを記述す
   るタプルのシーケンスです。各タプルの最初の要素は、残りのタプル要素
   の解釈方法を指定する以下の3つの型指定子のうちのひとつでなければなり
   ません。

   os.POSIX_SPAWN_OPEN

      ("os.POSIX_SPAWN_OPEN", *fd*, *path*, *flags*, *mode*)

      "os.dup2(os.open(path, flags, mode), fd)" を実行します。

   os.POSIX_SPAWN_CLOSE

      ("os.POSIX_SPAWN_CLOSE", *fd*)

      "os.close(fd)" を実行します。

   os.POSIX_SPAWN_DUP2

      ("os.POSIX_SPAWN_DUP2", *fd*, *new_fd*)

      "os.dup2(fd, new_fd)" を実行します。

   os.POSIX_SPAWN_CLOSEFROM

      ("os.POSIX_SPAWN_CLOSEFROM", *fd*)

      Performs "os.closerange(fd, INF)".

   These tuples correspond to the C library
   "posix_spawn_file_actions_addopen()",
   "posix_spawn_file_actions_addclose()",
   "posix_spawn_file_actions_adddup2()", and
   "posix_spawn_file_actions_addclosefrom_np()" API calls used to
   prepare for the "posix_spawn()" call itself.

   The *setpgroup* argument will set the process group of the child to
   the value specified. If the value specified is 0, the child's
   process group ID will be made the same as its process ID. If the
   value of *setpgroup* is not set, the child will inherit the
   parent's process group ID. This argument corresponds to the C
   library "POSIX_SPAWN_SETPGROUP" flag.

   If the *resetids* argument is "True" it will reset the effective
   UID and GID of the child to the real UID and GID of the parent
   process. If the argument is "False", then the child retains the
   effective UID and GID of the parent. In either case, if the set-
   user-ID and set-group-ID permission bits are enabled on the
   executable file, their effect will override the setting of the
   effective UID and GID. This argument corresponds to the C library
   "POSIX_SPAWN_RESETIDS" flag.

   If the *setsid* argument is "True", it will create a new session ID
   for "posix_spawn". *setsid* requires "POSIX_SPAWN_SETSID" or
   "POSIX_SPAWN_SETSID_NP" flag. Otherwise, "NotImplementedError" is
   raised.

   The *setsigmask* argument will set the signal mask to the signal
   set specified. If the parameter is not used, then the child
   inherits the parent's signal mask. This argument corresponds to the
   C library "POSIX_SPAWN_SETSIGMASK" flag.

   The *sigdef* argument will reset the disposition of all signals in
   the set specified. This argument corresponds to the C library
   "POSIX_SPAWN_SETSIGDEF" flag.

   The *scheduler* argument must be a tuple containing the (optional)
   scheduler policy and an instance of "sched_param" with the
   scheduler parameters. A value of "None" in the place of the
   scheduler policy indicates that is not being provided. This
   argument is a combination of the C library
   "POSIX_SPAWN_SETSCHEDPARAM" and "POSIX_SPAWN_SETSCHEDULER" flags.

   引数 "path", "argv", "env" を指定して 監査イベント "os.posix_spawn"
   を送出します。

   Added in version 3.8.

   バージョン 3.13 で変更: *env* parameter accepts "None".
   "os.POSIX_SPAWN_CLOSEFROM" is available on platforms where
   "posix_spawn_file_actions_addclosefrom_np()" exists.

   Availability: Unix, not WASI, not Android, not iOS.

os.posix_spawnp(path, argv, env, *, file_actions=None, setpgroup=None, resetids=False, setsid=False, setsigmask=(), setsigdef=(), scheduler=None)

   Wraps the "posix_spawnp()" C library API for use from Python.

   Similar to "posix_spawn()" except that the system searches for the
   *executable* file in the list of directories specified by the
   "PATH" environment variable (in the same way as for "execvp(3)").

   引数 "path", "argv", "env" を指定して 監査イベント "os.posix_spawn"
   を送出します。

   Added in version 3.8.

   Availability: POSIX, not WASI, not Android, not iOS.

   See "posix_spawn()" documentation.

os.register_at_fork(*, before=None, after_in_parent=None, after_in_child=None)

   Register callables to be executed when a new child process is
   forked using "os.fork()" or similar process cloning APIs. The
   parameters are optional and keyword-only. Each specifies a
   different call point.

   * *before* is a function called before forking a child process.

   * *after_in_parent* is a function called from the parent process
     after forking a child process.

   * *after_in_child* is a function called from the child process.

   These calls are only made if control is expected to return to the
   Python interpreter.  A typical "subprocess" launch will not trigger
   them as the child is not going to re-enter the interpreter.

   Functions registered for execution before forking are called in
   reverse registration order.  Functions registered for execution
   after forking (either in the parent or in the child) are called in
   registration order.

   Note that "fork()" calls made by third-party C code may not call
   those functions, unless it explicitly calls "PyOS_BeforeFork()",
   "PyOS_AfterFork_Parent()" and "PyOS_AfterFork_Child()".

   There is no way to unregister a function.

   Availability: Unix, not WASI, not Android, not iOS.

   Added in version 3.7.

os.spawnl(mode, path, ...)
os.spawnle(mode, path, ..., env)
os.spawnlp(mode, file, ...)
os.spawnlpe(mode, file, ..., env)
os.spawnv(mode, path, args)
os.spawnve(mode, path, args, env)
os.spawnvp(mode, file, args)
os.spawnvpe(mode, file, args, env)

   新たなプロセス内でプログラム *path* を実行します。

   ("subprocess" モジュールが、新しいプロセスを実行して結果を取得する
   ための、より強力な機能を提供しています。この関数の代わりに
   "subprocess" モジュールを利用することが推奨されています。
   "subprocess" モジュールのドキュメントの、 古い関数を subprocess モ
   ジュールで置き換える セクションを参照してください )

   *mode* が "P_NOWAIT" の場合、この関数は新たなプロセスのプロセス ID
   を返します ; *mode* が "P_WAIT" の場合、子プロセスが正常に終了する
   とその終了コードが返ります。そうでない場合にはプロセスを kill した
   シグナル *signal* に対して "-signal" が返ります。 Windows では、プ
   ロセス ID は実際にはプロセスハンドル値になるので、 "waitpid()" 関数
   で使えます。

   Note on VxWorks, this function doesn't return "-signal" when the
   new process is killed. Instead it raises OSError exception.

   The "l" and "v" variants of the "spawn*" functions differ in how
   command-line arguments are passed.  The "l" variants are perhaps
   the easiest to work with if the number of parameters is fixed when
   the code is written; the individual parameters simply become
   additional parameters to the "spawnl*()" functions.  The "v"
   variants are good when the number of parameters is variable, with
   the arguments being passed in a list or tuple as the *args*
   parameter.  In either case, the arguments to the child process must
   start with the name of the command being run.

   末尾近くに "p" をもつ型 ("spawnlp()", "spawnlpe()", "spawnvp()",
   "spawnvpe()") は、プログラム *file* を探すために環境変数 "PATH" を
   利用します。環境変数が ( 次の段で述べる "spawn*e" 型関数で ) 置き換
   えられる場合、環境変数は "PATH" を決定する上の情報源として使われま
   す。その他の型、 "spawnl()", "spawnle()", "spawnv()", および
   "spawnve()" では、実行コードを探すために "PATH" を使いません。
   *path* には適切に設定された絶対パスまたは相対パスが入っていなくては
   なりません。

   "spawnle()", "spawnlpe()", "spawnve()", および "spawnvpe()" (すべて
   末尾に "e" がついています) では、 *env* 引数は新たなプロセスで利用
   される環境変数を定義するためのマップ型でなくてはなりません ;
   "spawnl()" 、 "spawnlp()" 、 "spawnv()" 、および "spawnvp()" では、
   すべて新たなプロセスは現在のプロセスの環境を引き継ぎます。 *env* 辞
   書のキーと値はすべて文字列である必要があります。不正なキーや値を与
   えると関数が失敗し、 "127" を返します。

   例えば、以下の "spawnlp()" および "spawnvpe()" 呼び出しは等価です

      import os
      os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')

      L = ['cp', 'index.html', '/dev/null']
      os.spawnvpe(os.P_WAIT, 'cp', L, os.environ)

   引数 "mode", "path", "args", "env" を指定して 監査イベント
   "os.spawn" を送出します。

   Availability: Unix, Windows, not WASI, not Android, not iOS.

   "spawnlp()" 、 "spawnlpe()" 、 "spawnvp()" 、および "spawnvpe()" は
   Windows では利用できません。 "spawnle()" および "spawnve()" は
   Windows においてスレッドセーフではありません ; 代わりに
   "subprocess" モジュールの利用を推奨します。

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

   バージョン 3.14 で非推奨: These functions are *soft deprecated* and
   should no longer be used to write new code. The "subprocess" module
   is recommended instead.

os.P_NOWAIT
os.P_NOWAITO

   Possible values for the *mode* parameter to the "spawn*" family of
   functions.  If either of these values is given, the "spawn*"
   functions will return as soon as the new process has been created,
   with the process id as the return value.

   Availability: Unix, Windows.

os.P_WAIT

   Possible value for the *mode* parameter to the "spawn*" family of
   functions.  If this is given as *mode*, the "spawn*" functions will
   not return until the new process has run to completion and will
   return the exit code of the process the run is successful, or
   "-signal" if a signal kills the process.

   Availability: Unix, Windows.

os.P_DETACH
os.P_OVERLAY

   "spawn*" 関数ファミリに対する *mode* パラメタとして取れる値です。こ
   れらの値は上の値よりもやや可搬性において劣っています。 "P_DETACH"
   は "P_NOWAIT" に似ていますが、新たなプロセスは呼び出しプロセスのコ
   ンソールから切り離され (detach) ます。 "P_OVERLAY" が使われた場合、
   現在のプロセスは置き換えられます。したがって "spawn*" は返りません
   。

   Availability: Windows.

os.startfile(path[, operation][, arguments][, cwd][, show_cmd])

   ファイルを関連付けられたアプリケーションを使ってスタートします。

   When *operation* is not specified, this acts like double-clicking
   the file in Windows Explorer, or giving the file name as an
   argument to the **start** command from the interactive command
   shell: the file is opened with whatever application (if any) its
   extension is associated.

   When another *operation* is given, it must be a "command verb" that
   specifies what should be done with the file. Common verbs
   documented by Microsoft are "'open'", "'print'" and  "'edit'" (to
   be used on files) as well as "'explore'" and "'find'" (to be used
   on directories).

   When launching an application, specify *arguments* to be passed as
   a single string. This argument may have no effect when using this
   function to launch a document.

   The default working directory is inherited, but may be overridden
   by the *cwd* argument. This should be an absolute path. A relative
   *path* will be resolved against this argument.

   Use *show_cmd* to override the default window style. Whether this
   has any effect will depend on the application being launched.
   Values are integers as supported by the Win32 "ShellExecute()"
   function.

   "startfile()" returns as soon as the associated application is
   launched. There is no option to wait for the application to close,
   and no way to retrieve the application's exit status.  The *path*
   parameter is relative to the current directory or *cwd*.  If you
   want to use an absolute path, make sure the first character is not
   a slash ("'/'")  Use "pathlib" or the "os.path.normpath()" function
   to ensure that paths are properly encoded for Win32.

   To reduce interpreter startup overhead, the Win32 "ShellExecute()"
   function is not resolved until this function is first called.  If
   the function cannot be resolved, "NotImplementedError" will be
   raised.

   引数 "path", "operation" を指定して 監査イベント "os.startfile" を
   送出します。

   Raises an auditing event "os.startfile/2" with arguments "path",
   "operation", "arguments", "cwd", "show_cmd".

   Availability: Windows.

   バージョン 3.10 で変更: Added the *arguments*, *cwd* and *show_cmd*
   arguments, and the "os.startfile/2" audit event.

os.system(command)

   Execute the command (a string) in a subshell.  This is implemented
   by calling the Standard C function "system()", and has the same
   limitations. Changes to "sys.stdin", etc. are not reflected in the
   environment of the executed command. If *command* generates any
   output, it will be sent to the interpreter standard output stream.
   The C standard does not specify the meaning of the return value of
   the C function, so the return value of the Python function is
   system-dependent.

   On Unix, the return value is the exit status of the process encoded
   in the format specified for "wait()".

   Windows では、返り値は *command* を実行した後にシステムシェルから返
   される値です。シェルは通常 **cmd.exe** であり、返す値は実行したコマ
   ンドの終了ステータスになります。シェルの種類は Windows の環境変数
   "COMSPEC": に指定されています。ネイティブでないシェルを使用している
   場合は、そのドキュメントを参照してください。

   The "subprocess" module provides more powerful facilities for
   spawning new processes and retrieving their results; using that
   module is recommended to using this function.  See the 古い関数を
   subprocess モジュールで置き換える section in the "subprocess"
   documentation for some helpful recipes.

   On Unix, "waitstatus_to_exitcode()" can be used to convert the
   result (exit status) into an exit code. On Windows, the result is
   directly the exit code.

   引数 "command" を指定して 監査イベント "os.system" を送出します。

   Availability: Unix, Windows, not WASI, not Android, not iOS.

os.times()

   現在の全体的なプロセス時間を返します。返り値は 5 個の属性を持つオブ
   ジェクトになります:

   * "user" - user time

   * "system" - system time

   * "children_user" - user time of all child processes

   * "children_system" - system time of all child processes

   * "elapsed" - elapsed real time since a fixed point in the past

   後方互換性のため、このオブジェクトは 5 個のアイテム "user" 、
   "system" 、 "children_user" 、 "children_system" 、および "elapsed"
   を持つタプルのようにも振る舞います。

   See the Unix manual page *times(2)* and times(3) manual page on
   Unix or the GetProcessTimes MSDN on Windows. On Windows, only
   "user" and "system" are known; the other attributes are zero.

   Availability: Unix, Windows.

   バージョン 3.3 で変更: 返り値の型が、タプルから属性名のついたタプル
   ライクオブジェクトに変更されました。

os.wait()

   子プロセスの実行完了を待機し、子プロセスの pid と終了コードインジケ
   ーター --- 16 ビットの数値で、下位バイトがプロセスを kill したシグ
   ナル番号、上位バイトが終了ステータス ( シグナル番号がゼロの場合 )
   --- の入ったタプルを返します ; コアダンプファイルが生成された場合、
   下位バイトの最上桁ビットが立てられます。

   If there are no children that could be waited for,
   "ChildProcessError" is raised.

   戻り値の終了ステータスを終了コードに変換するために
   "waitstatus_to_exitcode()" を使うことができます。

   Availability: Unix, not WASI, not Android, not iOS.

   参考:

     The other "wait*()" functions documented below can be used to
     wait for the completion of a specific child process and have more
     options. "waitpid()" is the only one also available on Windows.

os.waitid(idtype, id, options, /)

   Wait for the completion of a child process.

   *idtype* can be "P_PID", "P_PGID", "P_ALL", or (on Linux)
   "P_PIDFD". The interpretation of *id* depends on it; see their
   individual descriptions.

   *options* is an OR combination of flags.  At least one of
   "WEXITED", "WSTOPPED" or "WCONTINUED" is required; "WNOHANG" and
   "WNOWAIT" are additional optional flags.

   The return value is an object representing the data contained in
   the "siginfo_t" structure with the following attributes:

   * "si_pid" (process ID)

   * "si_uid" (real user ID of the child)

   * "si_signo" (always "SIGCHLD")

   * "si_status" (the exit status or signal number, depending on
     "si_code")

   * "si_code" (see "CLD_EXITED" for possible values)

   If "WNOHANG" is specified and there are no matching children in the
   requested state, "None" is returned. Otherwise, if there are no
   matching children that could be waited for, "ChildProcessError" is
   raised.

   Availability: Unix, not WASI, not Android, not iOS.

   Added in version 3.3.

   バージョン 3.13 で変更: This function is now available on macOS as
   well.

os.waitpid(pid, options, /)

   この関数の詳細は Unix と Windows で異なります。

   Unix の場合 : プロセス id *pid* で与えられた子プロセスの完了を待機
   し、子プロセスのプロセス id と ("wait()" と同様にコード化された )
   終了ステータスインジケーターからなるタプルを返します。この関数の動
   作は *options* によって変わります。通常の操作では "0" にします。

   *pid* が "0" よりも大きい場合、 "waitpid()" は特定のプロセスのステ
   ータス情報を要求します。 *pid* が "0" の場合、現在のプロセスグルー
   プ内の任意の子プロセスの状態に対する要求です。 *pid* が "-1" の場合
   、現在のプロセスの任意の子プロセスに対する要求です。 *pid* が "-1"
   よりも小さい場合、プロセスグループ "-pid" ( すなわち *pid* の絶対値
   ) 内の任意のプロセスに対する要求です。

   *options* is an OR combination of flags.  If it contains "WNOHANG"
   and there are no matching children in the requested state, "(0, 0)"
   is returned.  Otherwise, if there are no matching children that
   could be waited for, "ChildProcessError" is raised.  Other options
   that can be used are "WUNTRACED" and "WCONTINUED".

   Windows では、プロセスハンドル *pid* を指定してプロセスの終了を待っ
   て、 *pid* と、終了ステータスを 8bit 左シフトした値のタプルを返しま
   す。 ( シフトは、この関数をクロスプラットフォームで利用しやすくする
   ために行われます ) "0" 以下の *pid* は Windows では特別な意味を持っ
   ておらず、例外を発生させます。 *options* の値は効果がありません。
   *pid* は、子プロセスで無くても、プロセス ID を知っているどんなプロ
   セスでも参照することが可能です。 "spawn*" 関数を "P_NOWAIT" と共に
   呼び出した場合、適切なプロセスハンドルが返されます。

   戻り値の終了ステータスを終了コードに変換するために
   "waitstatus_to_exitcode()" を使うことができます。

   Availability: Unix, Windows, not WASI, not Android, not iOS.

   バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
   外を送出しなかった場合、この関数は "InterruptedError" 例外を送出す
   る代わりにシステムコールを再試行するようになりました (論拠について
   は **PEP 475** を参照してください)。

os.wait3(options)

   "waitpid()" に似ていますが、プロセス id を引数に取らず、子プロセス
   id 、終了ステータスインジケータ、リソース使用情報の 3 要素からなる
   タプルを返します。リソース使用情報の詳しい情報は
   "resource.getrusage()" を参照してください。*options* 引数は
   "waitpid()" および "wait4()" に渡されるものと同じです。

   戻り値の終了ステータスを終了コードに変換するために
   "waitstatus_to_exitcode()" を使うことができます。

   Availability: Unix, not WASI, not Android, not iOS.

os.wait4(pid, options)

   "waitpid()" に似ていますが、子プロセス id 、終了ステータスインジケ
   ータ、リソース使用情報の 3 要素からなるタプルを返します。リソース使
   用情報の詳しい情報は "resource.getrusage()" を参照してください。
   "wait4()" の引数は "waitpid()" に与えられるものと同じです。

   戻り値の終了ステータスを終了コードに変換するために
   "waitstatus_to_exitcode()" を使うことができます。

   Availability: Unix, not WASI, not Android, not iOS.

os.P_PID
os.P_PGID
os.P_ALL
os.P_PIDFD

   "waitid()" の *idtype* に指定できる値です。これらは *id* がどう解釈
   されるかに影響します:

   * "P_PID" - wait for the child whose PID is *id*.

   * "P_PGID" - wait for any child whose progress group ID is *id*.

   * "P_ALL" - wait for any child; *id* is ignored.

   * "P_PIDFD" - wait for the child identified by the file descriptor
     *id* (a process file descriptor created with "pidfd_open()").

   Availability: Unix, not WASI, not Android, not iOS.

   注釈:

     "P_PIDFD" is only available on Linux >= 5.4.

   Added in version 3.3.

   Added in version 3.9: The "P_PIDFD" constant.

os.WCONTINUED

   This *options* flag for "waitpid()", "wait3()", "wait4()", and
   "waitid()" causes child processes to be reported if they have been
   continued from a job control stop since they were last reported.

   Availability: Unix, not WASI, not Android, not iOS.

os.WEXITED

   This *options* flag for "waitid()" causes child processes that have
   terminated to be reported.

   The other "wait*" functions always report children that have
   terminated, so this option is not available for them.

   Availability: Unix, not WASI, not Android, not iOS.

   Added in version 3.3.

os.WSTOPPED

   This *options* flag for "waitid()" causes child processes that have
   been stopped by the delivery of a signal to be reported.

   This option is not available for the other "wait*" functions.

   Availability: Unix, not WASI, not Android, not iOS.

   Added in version 3.3.

os.WUNTRACED

   This *options* flag for "waitpid()", "wait3()", and "wait4()"
   causes child processes to also be reported if they have been
   stopped but their current state has not been reported since they
   were stopped.

   This option is not available for "waitid()".

   Availability: Unix, not WASI, not Android, not iOS.

os.WNOHANG

   This *options* flag causes "waitpid()", "wait3()", "wait4()", and
   "waitid()" to return right away if no child process status is
   available immediately.

   Availability: Unix, not WASI, not Android, not iOS.

os.WNOWAIT

   This *options* flag causes "waitid()" to leave the child in a
   waitable state, so that a later "wait*()" call can be used to
   retrieve the child status information again.

   This option is not available for the other "wait*" functions.

   Availability: Unix, not WASI, not Android, not iOS.

os.CLD_EXITED
os.CLD_KILLED
os.CLD_DUMPED
os.CLD_TRAPPED
os.CLD_STOPPED
os.CLD_CONTINUED

   "waitid()" の返り値の "si_code" に設定され得る値です。

   Availability: Unix, not WASI, not Android, not iOS.

   Added in version 3.3.

   バージョン 3.9 で変更: "CLD_KILLED" と "CLD_STOPPED" が追加されまし
   た。

os.waitstatus_to_exitcode(status)

   待機ステータスを終了コードに変換します。

   Unix の場合:

   * 子プロセスが正常終了した場合 ("WIFEXITED(status)``が真の場合)、子
     プロセスの終了ステータス (``WEXITSTATUS(status)") を返します: 戻
     り値は0または正の整数です。

   * 子プロセスがシグナルによって終了した場合 ("WIFSIGNALED(status)``
     が真の場合)、子プロセスを終了したシグナルの番号に負符号をつけた
     ``-signum" ("-WTERMSIG(status)") を返します: 戻り値は負の整数です
     。

   * それ以外の場合、 "ValueError" 例外を送出します。

   Windows の場合、 *status* を8ビット右にシフトした値を返します。

   Unix の場合、プロセスがトレースされているか "waitpid()" が
   "WUNTRACED" オプションをつけて実行されている場合、呼び出しもとは最
   初に "WIFSTOPPED(status)" が真であるかを確認しなければなりません。
   この関数は "WIFSTOPPED(status)" が真の場合呼び出してはいけません。

   参考:

     "WIFEXITED()", "WEXITSTATUS()", "WIFSIGNALED()", "WTERMSIG()",
     "WIFSTOPPED()", "WSTOPSIG()" 関数。

   Availability: Unix, Windows, not WASI, not Android, not iOS.

   Added in version 3.9.

以下の関数は "system()" 、 "wait()" 、あるいは "waitpid()" が返すプロ
セス状態コードを引数にとります。これらの関数はプロセスの配置を決めるた
めに利用できます。

os.WCOREDUMP(status, /)

   プロセスに対してコアダンプが生成されていた場合には "True" を、それ
   以外の場合は "False" を返します。

   この関数は "WIFSIGNALED()" が真である場合のみ使用されるべきです。

   Availability: Unix, not WASI, not Android, not iOS.

os.WIFCONTINUED(status)

   Return "True" if a stopped child has been resumed by delivery of
   "SIGCONT" (if the process has been continued from a job control
   stop), otherwise return "False".

   "WCONTINUED" オプションを参照してください。

   Availability: Unix, not WASI, not Android, not iOS.

os.WIFSTOPPED(status)

   プロセスがシグナルの送信によって中断させられた場合に "True" を返し
   ます。それ以外の場合は "False" を返します。

   "WIFSTOPPED()" は "waitpid()" が "WUNTRACED" オプションを使って実行
   されたか、もしくはプロセスがトレースされている場合 (*ptrace(2)* を
   参照してください) にのみ "True" を返します。

   Availability: Unix, not WASI, not Android, not iOS.

os.WIFSIGNALED(status)

   プロセスがシグナルによって終了させられた場合に "True" を返します。
   そうでない場合は "False" を返します。

   Availability: Unix, not WASI, not Android, not iOS.

os.WIFEXITED(status)

   プロセスが正常終了した場合、すなわち "exit()" や "_exit()" を呼び出
   したか、もしくは "main()" から戻ることにより終了した場合に "True"
   を返します。それ以外は "False" を返します。

   Availability: Unix, not WASI, not Android, not iOS.

os.WEXITSTATUS(status)

   プロセスの終了ステータスを返します。

   この関数は "WIFEXITED()" が真である場合のみ使用されるべきです。

   Availability: Unix, not WASI, not Android, not iOS.

os.WSTOPSIG(status)

   プロセスを停止させたシグナル番号を返します。

   この関数は "WIFSTOPPED()" が真である場合のみ使用されるべきです。

   Availability: Unix, not WASI, not Android, not iOS.

os.WTERMSIG(status)

   プロセスを終了させたシグナルの番号を返します。

   この関数は "WIFSIGNALED()" が真である場合のみ使用されるべきです。

   Availability: Unix, not WASI, not Android, not iOS.


スケジューラーへのインターフェイス
==================================

以下の関数は、オペレーティングシステムがプロセスに CPU 時間を割り当て
る方法を制御します。これらは一部の Unix プラットフォームでのみ利用可能
です。詳しくは Unix マニュアルページを参照してください。

Added in version 3.3.

次のスケジューリングポリシーは、オペレーティングシステムでサポートされ
ていれば公開されます。

os.SCHED_OTHER

   デフォルトのスケジューリングポリシーです。

os.SCHED_BATCH

   常にCPUに負荷のかかる (CPU-intensive) プロセス用のポリシーです。他
   の対話式プロセスなどの応答性を維持するよう試みます。

os.SCHED_DEADLINE

   Scheduling policy for tasks with deadline constraints.

   Added in version 3.14.

os.SCHED_IDLE

   非常に優先度の低いバックグラウンドタスク用のスケジューリングポリシ
   ーです。

os.SCHED_NORMAL

   Alias for "SCHED_OTHER".

   Added in version 3.14.

os.SCHED_SPORADIC

   散発的なサーバープログラム用のスケジューリングポリシーです。

os.SCHED_FIFO

   FIFO (First In, First Out) 型のスケジューリングポリシーです。

os.SCHED_RR

   ラウンドロビン型のスケジューリングポリシーです。

os.SCHED_RESET_ON_FORK

   このフラグは他のスケジューリングポリシーとともに論理和指定できます
   。このフラグが与えられたプロセスが fork されると、その子プロセスの
   スケジューリングポリシーおよび優先度はデフォルトにリセットされます
   。

class os.sched_param(sched_priority)

   このクラスは、"sched_setparam()"、"sched_setscheduler()"、および
   "sched_getparam()" で使用される、調節可能なスケジューリングパラメー
   ターを表します。これはイミュータブルです。

   現在、一つの引数のみ指定できます:

   sched_priority

      スケジューリングポリシーのスケジューリング優先度です。

os.sched_get_priority_min(policy)

   *policy* の最小優先度値を取得します。*policy* には上記のスケジュー
   リングポリシー定数の一つを指定します。

os.sched_get_priority_max(policy)

   *policy* の最大優先度値を取得します。*policy* には上記のスケジュー
   リングポリシー定数の一つを指定します。

os.sched_setscheduler(pid, policy, param, /)

   PID *pid* のプロセスのスケジューリングポリシーを設定します。*pid*
   が 0 の場合、呼び出しプロセスを意味します。*policy* には上記のスケ
   ジューリングポリシー定数の一つを指定します。*param* は
   "sched_param" のインスタンスです。

os.sched_getscheduler(pid, /)

   PID *pid* のプロセスのスケジューリングポリシーを返します。*pid* が
   0 の場合、呼び出しプロセスを意味します。返り値は上記のスケジューリ
   ングポリシー定数の一つになります。

os.sched_setparam(pid, param, /)

   PID *pid* を持つプロセスのスケジューリングパラメータを設定します。
   *pid* を 0 とした場合呼び出しプロセスを意味します。 *param* は
   "sched_param" インスタンスです。

os.sched_getparam(pid, /)

   PID *pid* のプロセスのスケジューリングパラメーターを "sched_param"
   のインスタンスとして返します。*pid* が 0 の場合、呼び出しプロセスを
   意味します。

os.sched_rr_get_interval(pid, /)

   PID *pid* のプロセスのラウンドロビンクォンタム (秒) を返します。
   *pid* が 0 の場合、呼び出しプロセスを意味します。

os.sched_yield()

   Voluntarily relinquish the CPU. See *sched_yield(2)* for details.

os.sched_setaffinity(pid, mask, /)

   PID *pid* のプロセス (0 であれば現在のプロセス) を CPU の集合に制限
   します。*mask* はプロセスを制限する CPU の集合を表す整数のイテラブ
   ルなオブジェクトです。

os.sched_getaffinity(pid, /)

   Return the set of CPUs the process with PID *pid* is restricted to.

   If *pid* is zero, return the set of CPUs the calling thread of the
   current process is restricted to.

   See also the "process_cpu_count()" function.


雑多なシステム情報
==================

os.confstr(name, /)

   システム設定値を文字列で返します。 *name* には取得したい設定名を指
   定します ; この値は定義済みのシステム値名を表す文字列にすることがで
   きます ; 名前は多くの標準 (POSIX.1 、 Unix 95 、 Unix 98 その他 )
   で定義されています。ホストオペレーティングシステムの関知する名前は
   "confstr_names" 辞書のキーとして与えられています。このマップ型オブ
   ジェクトに入っていない設定変数については、 *name* に整数を渡しても
   かまいません。

   *name* に指定された設定値が定義されていない場合、 "None" を返します
   。

   *name* が文字列で、かつ不明の場合、 "ValueError" を送出します。
   *name* の指定値がホストシステムでサポートされておらず、
   "confstr_names" にも入っていない場合、 "errno.EINVAL" をエラー番号
   として "OSError" を送出します。

   Availability: Unix.

os.confstr_names

   "confstr()" が受理する名前を、ホストオペレーティングシステムで定義
   されている整数値に対応付けている辞書です。この辞書はシステムでどの
   設定名が定義されているかを決定するために利用できます。

   Availability: Unix.

os.cpu_count()

   Return the number of logical CPUs in the **system**. Returns "None"
   if undetermined.

   The "process_cpu_count()" function can be used to get the number of
   logical CPUs usable by the calling thread of the **current
   process**.

   Added in version 3.4.

   バージョン 3.13 で変更: If "-X cpu_count" is given or
   "PYTHON_CPU_COUNT" is set, "cpu_count()" returns the override value
   *n*.

os.getloadavg()

   過去 1 分、 5 分、および 15 分間の、システムの実行キューの平均プロ
   セス数を返します。平均負荷が得られない場合には "OSError" を送出しま
   す。

   Availability: Unix.

os.process_cpu_count()

   Get the number of logical CPUs usable by the calling thread of the
   **current process**. Returns "None" if undetermined. It can be less
   than "cpu_count()" depending on the CPU affinity.

   The "cpu_count()" function can be used to get the number of logical
   CPUs in the **system**.

   If "-X cpu_count" is given or "PYTHON_CPU_COUNT" is set,
   "process_cpu_count()" returns the override value *n*.

   See also the "sched_getaffinity()" function.

   Added in version 3.13.

os.sysconf(name, /)

   整数値のシステム設定値を返します。 *name* で指定された設定値が定義
   されていない場合、 "-1" が返されます。 *name* に関するコメントとし
   ては、 "confstr()" で述べた内容が同様に当てはまります ; 既知の設定
   名についての情報を与える辞書は "sysconf_names" で与えられています。

   Availability: Unix.

os.sysconf_names

   "sysconf()" が受理する名前を、ホストオペレーティングシステムで定義
   されている整数値に対応付けている辞書です。この辞書はシステムでどの
   設定名が定義されているかを決定するために利用できます。

   Availability: Unix.

   バージョン 3.11 で変更: Add "'SC_MINSIGSTKSZ'" name.

以下のデータ値はパス名編集操作をサポートするために利用されます。これら
の値はすべてのプラットフォームで定義されています。

パス名に対する高水準の操作は "os.path" モジュールで定義されています。

os.curdir

   現在のディレクトリ参照するためにオペレーティングシステムで使われる
   文字列定数です。 POSIX と Windows では "'.'" になります。 "os.path"
   からも利用できます。

os.pardir

   親ディレクトリを参照するためにオペレーティングシステムで使われる文
   字列定数です。 POSIX と Windows では "'..'" になります。 "os.path"
   からも利用できます。

os.sep

   パス名を要素に分割するためにオペレーティングシステムで利用されてい
   る文字です。例えば POSIX では "'/'" で、 Windows では "'\\'" です。
   しかし、このことを知っているだけではパス名を解析したり、パス名同士
   を結合したりするには不十分です --- こうした操作には
   "os.path.split()" や "os.path.join()" を使用してください --- が、た
   まに便利なこともあります。 "os.path" からも利用できます。

os.altsep

   文字パス名を要素に分割する際にオペレーティングシステムで利用される
   もう一つの文字で、分割文字が一つしかない場合には "None" になります
   。この値は "sep" がバックスラッシュとなっている DOS や Windows シス
   テムでは "'/'" に設定されています。 "os.path" からも利用できます。

os.extsep

   ベースのファイル名と拡張子を分ける文字です。例えば、 "os.py" であれ
   ば "'.'" です。 "os.path" からも利用できます。

os.pathsep

   ("PATH" のような ) サーチパス内の要素を分割するためにオペレーティン
   グシステムが慣習的に用いる文字で、 POSIX における "':'" や DOS およ
   び Windows における "';'" に相当します。 "os.path" からも利用できま
   す。

os.defpath

   "exec*p*" や "spawn*p*" において、環境変数辞書内に "'PATH'" キーが
   ない場合に使われる標準設定のサーチパスです。 "os.path" からも利用で
   きます。

os.linesep

   現在のプラットフォーム上で行を分割 ( あるいは終端 ) するために用い
   られている文字列です。この値は例えば POSIX での "'\n'" や Mac OS で
   の "'\r'" のように、単一の文字にもなりますし、例えば Windows での
   "'\r\n'" のように複数の文字列にもなります。テキストモードで開いたフ
   ァイルに書き込む時には、 *os.linesep* を利用しないでください。すべ
   てのプラットフォームで、単一の "'\n'" を使用してください。

os.devnull

   ヌルデバイスのファイルパスです。例えば POSIX では "'/dev/null'" で
   、 Windows では "'nul'" です。この値は "os.path" からも利用できます
   。

os.RTLD_LAZY
os.RTLD_NOW
os.RTLD_GLOBAL
os.RTLD_LOCAL
os.RTLD_NODELETE
os.RTLD_NOLOAD
os.RTLD_DEEPBIND

   "setdlopenflags()" 関数と "getdlopenflags()" 関数と一緒に使用するフ
   ラグ。それぞれのフラグの意味については、Unix マニュアルの
   *dlopen(3)* ページを参照してください。

   Added in version 3.3.


乱数
====

os.getrandom(size, flags=0)

   最大で *size* バイトからなるランダムなバイト列を返します。この関数
   は要求されたバイト数よりも少ないバイト数を返すことがあります。

   バイト列は、ユーザー空間の乱数生成器や暗号目的ののシードとして利用
   できます。

   "getrandom()" はデバイスドライバや他の環境ノイズ源から収集されたエ
   ントロピーに頼っています。不必要な大量のデータの読出しは、
   "/dev/random" と "/dev/urandom" デバイスの他のユーザーに負の影響を
   与えるでしょう。

   The flags argument is a bit mask that can contain zero or more of
   the following values ORed together: "os.GRND_RANDOM" and
   "GRND_NONBLOCK".

   Linux getrandom() manual page も参照してください。

   Availability: Linux >= 3.17.

   Added in version 3.6.

os.urandom(size, /)

   暗号に関する用途に適した *size* バイトからなるランダムなバイト文字
   列を返します。

   この関数は OS 固有の乱数発生源からランダムなバイト列を生成して返し
   ます。この関数の返すデータは暗号を用いたアプリケーションで十分利用
   できる程度に予測不能ですが、実際のクオリティは OS の実装によって異
   なります。

   Linux では、 "getrandom()" システムコールが利用可能ならブロッキング
   モードで呼び出されます: すなわちシステムの urandom エントロピープー
   ルが初期化されるまで (128 ビットのエントロピーがカーネルにより収集
   されるまで) 処理がブロックされます。論拠については **PEP 524** を参
   照してください。 Linux では、 ("GRND_NONBLOCK" フラグを使って) 非ブ
   ロッキングモードでランダムなバイトを取得したり、システムの urandom
   エントロピープールが初期化されるまでポーリングするために
   "getrandom()" 関数を利用することができます。

   Unix ライクなシステムでは、ランダムなバイトは "/dev/urandom" デバイ
   スから読み込みます。 "/dev/urandom" デバイスが利用できないか、もし
   くは読み取り不可のときは、 "NotImplementedError" 例外が送出されます
   。

   Windowsで、 "BCryptGenRandom()" を使用します。

   参考:

     "secrets" モジュールは高レベルの乱数生成機能を提供します。プラッ
     トフォームが提供する乱数生成器に対する簡便なインターフェースにつ
     いては、 "random.SystemRandom" を参照してください。

   バージョン 3.5 で変更: Linux 3.17 以降では、使用可能な場合に
   "getrandom()"  システムコールが使用されるようになりました。OpenBSD
   5.6 以降では、C "getentropy()" 関数が使用されるようになりました。こ
   れらの関数は、内部ファイル記述子を使用しません。

   バージョン 3.5.2 で変更: Linux において、 "getrandom()" システムコ
   ールがブロックするなら (urandom エントロピープールが初期化されてい
   なければ) 、 "/dev/urandom" を読む方法にフォールバックします。

   バージョン 3.6 で変更: Linuxで、 セキュリティを高めるために、
   "getrandom()" をブロッキングモードで使用するようになりました。

   バージョン 3.11 で変更: On Windows, "BCryptGenRandom()" is used
   instead of "CryptGenRandom()" which is deprecated.

os.GRND_NONBLOCK

   デフォルトでは、"getrandom()" は "/dev/random" から読み込んだときに
   ランダムなバイトが存在しない場合や、 "/dev/urandom" から読み込んだ
   ときにエントロピープールが初期化されていない場合に処理をブロックし
   ます。

   "GRND_NONBLOCK" フラグがセットされると、 "getrandom()" はこれらの場
   合に処理をブロックせず、ただちに "BlockingIOError" 例外を送出します
   。

   Added in version 3.6.

os.GRND_RANDOM

   このビットがセットされた場合、 ランダムバイトは "/dev/urandom" プー
   ルの代わりに  "/dev/random" プールから取り出されます。

   Added in version 3.6.
