ecore_exe_example.c
This is a process that will send messages to a child and it will stop when it receives "quit".Check the Full tutorial
#include <stdio.h>
#include <string.h>
#include <Ecore.h>
#define BUFFER_SIZE 1024
static Eina_Bool
_msg_from_child_handler(void *data, int type, void *event)
{
char msg[BUFFER_SIZE];
{
fprintf(stdout, "Data too big for bugger. error\n");
}
msg[dataFromProcess->size] = 0;
if (strcmp(msg, "quit") == 0)
{
fprintf(stdout, "My child said to me, QUIT!\n");
}
else
fprintf(stdout, "I received a message from my child: %s\n", msg);
return ECORE_CALLBACK_DONE;
}
static Eina_Bool
_sendMessage(void *data)
{
static int numberOfMessages = 0;
char msg[BUFFER_SIZE];
sprintf(msg, " Message: %d\n", numberOfMessages);
numberOfMessages++;
fprintf(stderr, "Could not send my name to the child\n");
else
fprintf(stdout,
"I'm the father and I sent this message to the child: %s\n", msg);
}
int
main(int argc, char **argv)
{
pid_t childPid;
Ecore_Exe *childHandle;
goto exit;
ECORE_EXE_PIPE_READ, NULL);
if (childHandle == NULL)
{
fprintf(stderr, "Could not create a child process!\n");
}
childPid = ecore_exe_pid_get(childHandle);
if (childPid == -1)
fprintf(stderr, "Could not retrive the PID!\n");
else
fprintf(stdout, "The child process has PID:%d\n", childPid);
ecore_timer_add(1, _sendMessage, childHandle);
return EXIT_SUCCESS;
exit:
return EXIT_FAILURE;
}