Files
doc-fr/reference/pcntl/examples.xml
George Peter Banyard c5fae30d10 Sync with latest EN revision
Update revision number after typos in EN revision have been fixed,
Minor translations updated
Apply XML fixes from EN revision

git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@349979 c90b9560-bf6c-de11-be94-00142212c4b1
2020-05-25 18:17:11 +00:00

90 lines
1.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: aebf045bfb7f4f2350db5e1e908cf290be334075 Maintainer: yannick Status: ready -->
<!-- Reviewed: yes -->
<chapter xml:id="pcntl.examples" xmlns="http://docbook.org/ns/docbook">
&reftitle.examples;
<section xml:id="pcntl.example">
<title>Utilisation simple</title>
<para>
Cet exemple forke un processus démon, avec un gestionnaire de signaux.
</para>
<example>
<title>Exemple de contrôle de processus</title>
<programlisting role="php">
<![CDATA[
<?php
declare(ticks=1);
$pid = pcntl_fork();
if ($pid == -1) {
die("impossible de forker");
} else if ($pid) {
exit(); // nous sommes le processus père
} else {
// nous sommes le processus fils
}
// détachons le processus du terminal
if (posix_setsid() == -1) {
die("impossible de se détacher du terminal");
}
// configuration des gestionnaires de signaux
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
// boucle infinie
while (1) {
// exécution de quelque chose
}
function sig_handler($signo)
{
switch ($signo) {
case SIGTERM:
// gestion des tâches de terminaison
exit;
break;
case SIGHUP:
// gestion des tâches de redémarrage
break;
default:
// gestion des autres tâches
}
}
?>
]]>
</programlisting>
</example>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->