サブプロセスのSTDERR、STDOUT、およびSTDINを設定するには?

サブプロセスのSTDERR、STDOUT、およびSTDINを設定するには?

プログラムが実行されたときにfork()標準ストリームを設定するにはSTDOUTSTDINSTDERR

ベストアンサー1

Stdin、stdout、stderr は親プロセスから継承されます。必要に応じて、子プロセスによって新しいファイルを指すように変更されます。

fork(2)マニュアルページから:

   *  The  child inherits copies of the parent's set of open file descrip‐
      tors.  Each file descriptor in the child refers  to  the  same  open
      file  description (see open(2)) as the corresponding file descriptor
      in the parent.

おすすめ記事