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
_msg_from_child_handler(void *data, int type, void *event)
{
char msg[BUFFER_SIZE];
if (dataFromProcess->
size >= (BUFFER_SIZE - 1))
{
fprintf(stdout, "Data too big for bugger. error\n");
}
strncpy(msg, dataFromProcess->
data, dataFromProcess->
size);
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);
}
_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;
goto exit;
if (childHandle == NULL)
{
fprintf(stderr, "Could not create a child process!\n");
}
if (childPid == -1)
fprintf(stderr, "Could not retrive the PID!\n");
else
fprintf(stdout, "The child process has PID:%d\n", childPid);
return EXIT_SUCCESS;
exit:
return EXIT_FAILURE;
}