\hypertarget{ecore_exe_example_child_8c-example}{}\section{ecore\+\_\+exe\+\_\+example\+\_\+child.\+c}
This is a child process used to receive messages and send it back to its father.\+Check the \hyperlink{Ecore_exe_simple_example_c}{Full tutorial}


\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#include <stdio.h>}
\textcolor{preprocessor}{#include <unistd.h>}
\textcolor{preprocessor}{#include <Ecore.h>}

\textcolor{preprocessor}{#define BUFFER\_SIZE 1024}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_fd\_handler\_cb(\textcolor{keywordtype}{void} *data \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \hyperlink{group__Ecore__FD__Handler__Group_ga225121ed2123da4b52b76aa08d78c220}{Ecore\_Fd\_Handler} *fd\_handler EINA\_UNUSED)
\{
   \textcolor{keyword}{static} \textcolor{keywordtype}{int} numberOfMessages = 0;
   \textcolor{keywordtype}{char} message[BUFFER\_SIZE];

   \textcolor{keywordflow}{if} (!fgets(message, BUFFER\_SIZE, stdin))
     \textcolor{keywordflow}{return} \hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW};

   numberOfMessages++;

   \textcolor{keywordflow}{if} (numberOfMessages < 3)
     \{
        fprintf(stdout, \textcolor{stringliteral}{"My father sent this message to me:%s\(\backslash\)n"}, message);
        fflush(stdout);
        \textcolor{keywordflow}{return} \hyperlink{group__Ecore__Main__Loop__Group_ga1ee9db07f9a46a8b20fb83e1c6dbed09}{ECORE\_CALLBACK\_RENEW};
     \}
   \textcolor{keywordflow}{else}
     \{
        fprintf(stdout, \textcolor{stringliteral}{"quit\(\backslash\)n"});
        fflush(stdout);
        \hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}();
        \textcolor{keywordflow}{return} \hyperlink{group__Ecore__Main__Loop__Group_ga780091d7d49a4bb6cb753f12e1a3b19d}{ECORE\_CALLBACK\_DONE};
     \}
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \textcolor{keywordflow}{if} (!\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}())
     \textcolor{keywordflow}{goto} \hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error};

   \hyperlink{group__Ecore__FD__Handler__Group_ga832e68eb7f15912abeadef816bb5d2f5}{ecore\_main\_fd\_handler\_add}(STDIN\_FILENO,
                             \hyperlink{group__Ecore__FD__Handler__Group_ggab5644f471dfa3bd182619601d9b60608a1699f804eccf88e7e169a4a20f1d44e7}{ECORE\_FD\_READ},
                             \_fd\_handler\_cb,
                             NULL, NULL, NULL);
   \hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}();

   \hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}();

   \textcolor{keywordflow}{return} EXIT\_SUCCESS;

\hyperlink{namespaceefl_1_1eina_1_1log__level_a0eec9fe47d243634f680b56a7d768ec7}{error}:
   \textcolor{keywordflow}{return} EXIT\_FAILURE;
\}

\end{DoxyCodeInclude}
 