9
#define BUFFER_SIZE 1024
12
_msg_from_child_handler(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
14
Ecore_Exe_Event_Data *dataFromProcess = (Ecore_Exe_Event_Data *)event;
15
char msg[BUFFER_SIZE];
17
if (dataFromProcess->size >= (BUFFER_SIZE - 1))
19
printf("Data too big for bugger. error\n");
20
return ECORE_CALLBACK_DONE;
23
strncpy(msg, dataFromProcess->data, dataFromProcess->size);
24
msg[dataFromProcess->size] = 0;
26
if (strcmp(msg, "quit") == 0)
28
printf("My child said to me, QUIT!\n");
29
ecore_main_loop_quit();
32
printf("I received a message from my child: %s\n", msg);
34
return ECORE_CALLBACK_DONE;
38
_sendMessage(void *data)
40
static int numberOfMessages = 0;
41
Ecore_Exe *childHandle = (Ecore_Exe *)data;
42
char msg[BUFFER_SIZE];
44
sprintf(msg, " Message: %d\n", numberOfMessages);
47
if (ecore_exe_send(childHandle, msg, strlen(msg)) != EINA_TRUE)
48
fprintf(stderr, "Could not send my name to the child\n");
51
"I'm the father and I sent this message to the child: %s\n", msg);
53
return ECORE_CALLBACK_RENEW;
60
Ecore_Exe *childHandle;
65
childHandle = ecore_exe_pipe_run("./ecore_exe_example_child",
66
ECORE_EXE_PIPE_WRITE |
67
ECORE_EXE_PIPE_READ_LINE_BUFFERED |
68
ECORE_EXE_PIPE_READ, NULL);
70
if (childHandle == NULL)
72
fprintf(stderr, "Could not create a child process!\n");
76
childPid = ecore_exe_pid_get(childHandle);
79
fprintf(stderr, "Could not retrieve the PID!\n");
81
printf("The child process has PID:%u\n", (unsigned int)childPid);
83
ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _msg_from_child_handler, NULL);
84
ecore_timer_add(1, _sendMessage, childHandle);
86
ecore_main_loop_begin();
88
ecore_exe_free(childHandle);