- $CHILD_ERROR
- $?
-
The status returned by the last pipe close, backtick (
``) command, successful call towait()orwaitpid(), or from thesystem()operator. This is just the 16-bit status word returned by the traditional Unixwait()system call (or else is made up to look like it). Thus, the exit value of the subprocess is really ($? >> 8), and$? & 127gives which signal, if any, the process died from, and$? & 128reports whether there was a core dump.最後に close したパイプ、バッククォート (
``) コマンド、 成功したwait()または waitpid() 呼び出し、system()演算子が返した ステータス。 このステータスワードは伝統的な Unix のwait()システムコールが返した 16 ビットのステータス(またはそのように見えるもの)です。 従ってサブプロセスの exit 値は、実際には ($? >> 8) で、$? & 127は、もしあれば、そのプロセスを止めたシグナルで、$? & 128はコアダンプがあるかどうかを示します。Additionally, if the
h_errnovariable is supported in C, its value is returned via$?if anygethost*()function fails.さらに、C で
h_errno変数に対応している場合は、gethost*()が失敗したときに$?を通して返されます。If you have installed a signal handler for
SIGCHLD, the value of$?will usually be wrong outside that handler.SIGCHLDのシグナルハンドラを設定した場合、$?の値は通常ハンドラの外側では正しくない値となります。Inside an
ENDsubroutine$?contains the value that is going to be given toexit(). You can modify$?in anENDsubroutine to change the exit status of your program. For example:ENDサブルーチンの内側では$?にはexit()に渡されようとしている 値を含みます。 プログラムの終了ステータスを変更するために、ENDサブルーチン 内で$?を変更できます。 例えば:END { $? = 1 if $? == 255; # die would make it 255 }END { $? = 1 if $? == 255; # die は 255 }Under VMS, the pragma
use vmsish 'status'makes$?reflect the actual VMS exit status, instead of the default emulation of POSIX status; see "$?" in perlvms for details.VMS では、
use vmsish 'status'を指定すると、$?はPOSIX ステータスをエミュレートしたものではなく、 実際の VMS 終了ステータスを反映します; 詳細は "$?" in perlvms を 参照してください。Mnemonic: similar to sh and ksh.
記憶法: sh や ksh と同様。