Skip to content

Commit daea98d

Browse files
committed
pcntl-get-last-errorに追記
1 parent 62ca071 commit daea98d

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

reference/pcntl/functions/pcntl-get-last-error.xml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: b608b323883ac77489a31f8a1aa406e17c202bcb Maintainer: takagi Status: ready -->
3+
<!-- EN-Revision: 4ac5624be0dc8484a333514b605150e73cad06b8 Maintainer: takagi Status: ready -->
44

55
<refentry xml:id="function.pcntl-get-last-error" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
66
<refnamediv>
@@ -15,11 +15,9 @@
1515
<void />
1616
</methodsynopsis>
1717
<para>
18-
18+
直前に失敗した pcntl 関数によって設定されたエラー番号 (<literal>errno</literal>) を取得します。
19+
エラー番号に関連付けられたシステムエラーメッセージは、 <function>pcntl_strerror</function> を使用して確認できます。
1920
</para>
20-
21-
&warn.undocumented.func;
22-
2321
</refsect1>
2422

2523
<refsect1 role="parameters">
@@ -30,10 +28,38 @@
3028
<refsect1 role="returnvalues">
3129
&reftitle.returnvalues;
3230
<para>
33-
エラーコードを返します
31+
直前に失敗した pcntl 関数によって設定されたエラー番号 (<literal>errno</literal>) を返します。エラーが発生していない場合は、 0 を返します
3432
</para>
3533
</refsect1>
3634

35+
<refsect1 role="examples">
36+
&reftitle.examples;
37+
<example>
38+
<title><function>pcntl_get_last_error</function> の例</title>
39+
<para>
40+
この例では、存在しない子プロセスを待機しようと試みた後、対応するエラーメッセージを出力します。
41+
</para>
42+
<programlisting role="php">
43+
<![CDATA[
44+
<?php
45+
$pid = pcntl_wait($status);
46+
if ($pid === -1) {
47+
$errno = pcntl_get_last_error();
48+
$message = pcntl_strerror($errno);
49+
fwrite(STDERR, 'pcntl_wait がエラー番号' . $errno
50+
. 'で失敗しました: ' . $message . PHP_EOL);
51+
}
52+
]]>
53+
</programlisting>
54+
&example.outputs.similar;
55+
<screen>
56+
<![CDATA[
57+
pcntl_wait がエラー番号 10 で失敗しました: 子プロセスが存在しません
58+
]]>
59+
</screen>
60+
</example>
61+
</refsect1>
62+
3763
<refsect1 role="seealso">
3864
&reftitle.seealso;
3965
<simplelist>

0 commit comments

Comments
 (0)