{"id":6399,"date":"2026-01-28T16:07:54","date_gmt":"2026-01-28T15:07:54","guid":{"rendered":"https:\/\/workboot.fr\/ciela\/?page_id=6399"},"modified":"2026-01-28T17:14:48","modified_gmt":"2026-01-28T16:14:48","slug":"fork","status":"publish","type":"page","link":"https:\/\/workboot.fr\/ciela\/fork\/","title":{"rendered":"fork"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><code>fork()<\/code>&nbsp;=&nbsp;<strong>Je me copie moi-m\u00eame pour faire deux choses en parall\u00e8le !<\/strong>&nbsp;\u2728<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>       &#91;Processus unique]\n              |\n              | fork()\n              \u2b07\n        \u250c\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2510\n        \u25bc           \u25bc\n  &#91;Processus]  &#91;Processus]\n     Parent       Enfant<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Exemple simple d&rsquo;usage du fork<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">file :  fork.c <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;unistd.h>\n#include &lt;stdio.h>\n#include &lt;stdlib.h>\n\nint main() \n{\n    pid_t pid = fork();\n    if (pid == -1) \n    {\n        perror(\"fork failed\");\n        return EXIT_FAILURE;\n    }\n    if (pid == 0) \n    {\n        printf(\"Je suis le processus enfant\\n\");\n    } \n    else \n    {\n        printf(\"Je suis le processus parent\\n\");\n    }\n    return EXIT_SUCCESS;\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">un code amusant pour bien voir le P\u00e8re et le Fils<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Il faut 2 terminaux. Avec la commande <code>tty<\/code>, v\u00e9rifiez que vous avez :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\/dev\/pts\/1<\/code> pour afficher le p\u00e8re<\/li>\n\n\n\n<li><code>\/dev\/pts\/2<\/code> pour afficher le fils<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Ici, Luc Skywalker !<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">File : darkvador.c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;stdio.h>\n#include &lt;stdlib.h>\n#include &lt;unistd.h>\n#include &lt;fcntl.h>\n\nint main() \n{\n    int tty;\n    printf (\"Luc je suis ton p\u00e8re! \\n\");\n    \/* Cr\u00e9ation du processus enfant *\/\n    if (fork() == 0) \n    {\n        \/* ENFANT - \u00e9crit sur \/dev\/pts\/2  *\/\n        tty = open(\"\/dev\/pts\/2\", O_WRONLY);\n        write(tty, \"Je suis Luc SkyWalker !\\n\", 24);\n        close(tty);    \n    } \n    else \n    {\n        \/* PARENT - attend 3 secondes, puis \u00e9crit sur \/dev\/pts\/1*\/\n        sleep(3);\n        \n        tty = open(\"\/dev\/pts\/1\", O_WRONLY);\n        write(tty, \"C'est bien mon petit !\\n\", 23);\n        close(tty);\n    }\n    \n    return EXIT_SUCCESS;\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/darkvador.png\"><img loading=\"lazy\" decoding=\"async\" width=\"739\" height=\"525\" src=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/darkvador.png\" alt=\"\" class=\"wp-image-6412\" style=\"width:493px;height:auto\" srcset=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/darkvador.png 739w, https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/darkvador-300x213.png 300w\" sizes=\"auto, (max-width: 739px) 100vw, 739px\" \/><\/a><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignright size-full is-resized\"><a href=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/luc.png\"><img loading=\"lazy\" decoding=\"async\" width=\"739\" height=\"525\" src=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/luc.png\" alt=\"\" class=\"wp-image-6413\" style=\"aspect-ratio:1.4076393237319975;width:496px;height:auto\" srcset=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/luc.png 739w, https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/luc-300x213.png 300w\" sizes=\"auto, (max-width: 739px) 100vw, 739px\" \/><\/a><\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>fork()&nbsp;=&nbsp;Je me copie moi-m\u00eame pour faire deux choses en parall\u00e8le !&nbsp;\u2728 Exemple simple d&rsquo;usage du fork file : fork.c un code amusant pour bien voir le P\u00e8re et le Fils [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-6399","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>fork - workboot<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/workboot.fr\/ciela\/fork\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"fork - workboot\" \/>\n<meta property=\"og:description\" content=\"fork()&nbsp;=&nbsp;Je me copie moi-m\u00eame pour faire deux choses en parall\u00e8le !&nbsp;\u2728 Exemple simple d&rsquo;usage du fork file : fork.c un code amusant pour bien voir le P\u00e8re et le Fils [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/workboot.fr\/ciela\/fork\/\" \/>\n<meta property=\"og:site_name\" content=\"workboot\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-28T16:14:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/darkvador.png\" \/>\n\t<meta property=\"og:image:width\" content=\"739\" \/>\n\t<meta property=\"og:image:height\" content=\"525\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/fork\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/fork\\\/\",\"name\":\"fork - workboot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/fork\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/fork\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2026\\\/01\\\/darkvador.png\",\"datePublished\":\"2026-01-28T15:07:54+00:00\",\"dateModified\":\"2026-01-28T16:14:48+00:00\",\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/workboot.fr\\\/ciela\\\/fork\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/fork\\\/#primaryimage\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2026\\\/01\\\/darkvador.png\",\"contentUrl\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2026\\\/01\\\/darkvador.png\",\"width\":739,\"height\":525},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"name\":\"workboot\",\"description\":\"Open Source, Open Minds \",\"publisher\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\",\"name\":\"workboot\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"contentUrl\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"width\":1024,\"height\":950,\"caption\":\"workboot\"},\"image\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"fork - workboot","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/workboot.fr\/ciela\/fork\/","og_locale":"fr_FR","og_type":"article","og_title":"fork - workboot","og_description":"fork()&nbsp;=&nbsp;Je me copie moi-m\u00eame pour faire deux choses en parall\u00e8le !&nbsp;\u2728 Exemple simple d&rsquo;usage du fork file : fork.c un code amusant pour bien voir le P\u00e8re et le Fils [&hellip;]","og_url":"https:\/\/workboot.fr\/ciela\/fork\/","og_site_name":"workboot","article_modified_time":"2026-01-28T16:14:48+00:00","og_image":[{"width":739,"height":525,"url":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/darkvador.png","type":"image\/png"}],"twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/workboot.fr\/ciela\/fork\/","url":"https:\/\/workboot.fr\/ciela\/fork\/","name":"fork - workboot","isPartOf":{"@id":"https:\/\/workboot.fr\/ciela\/#website"},"primaryImageOfPage":{"@id":"https:\/\/workboot.fr\/ciela\/fork\/#primaryimage"},"image":{"@id":"https:\/\/workboot.fr\/ciela\/fork\/#primaryimage"},"thumbnailUrl":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/darkvador.png","datePublished":"2026-01-28T15:07:54+00:00","dateModified":"2026-01-28T16:14:48+00:00","inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/workboot.fr\/ciela\/fork\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/workboot.fr\/ciela\/fork\/#primaryimage","url":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/darkvador.png","contentUrl":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2026\/01\/darkvador.png","width":739,"height":525},{"@type":"WebSite","@id":"https:\/\/workboot.fr\/ciela\/#website","url":"https:\/\/workboot.fr\/ciela\/","name":"workboot","description":"Open Source, Open Minds ","publisher":{"@id":"https:\/\/workboot.fr\/ciela\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/workboot.fr\/ciela\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/workboot.fr\/ciela\/#organization","name":"workboot","url":"https:\/\/workboot.fr\/ciela\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/","url":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","contentUrl":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","width":1024,"height":950,"caption":"workboot"},"image":{"@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/"}}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/workboot.fr\/ciela\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"fork()&nbsp;=&nbsp;Je me copie moi-m\u00eame pour faire deux choses en parall\u00e8le !&nbsp;\u2728 Exemple simple d&rsquo;usage du fork file : fork.c un code amusant pour bien voir le P\u00e8re et le Fils [&hellip;]","_links":{"self":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/6399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/comments?post=6399"}],"version-history":[{"count":8,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/6399\/revisions"}],"predecessor-version":[{"id":6415,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/6399\/revisions\/6415"}],"wp:attachment":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/media?parent=6399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}