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
{
char msg[BUFFER_SIZE];
if (dataFromProcess->
size >= (BUFFER_SIZE - 1))
{
printf("Data too big for bugger. error\n");
}
strncpy(msg, dataFromProcess->
data, dataFromProcess->
size);
msg[dataFromProcess->
size] = 0;
if (strcmp(msg, "quit") == 0)
{
printf("My child said to me, QUIT!\n");
}
else
printf("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
printf(
"I'm the father and I sent this message to the child: %s\n", msg);
}
int
main(void)
{
pid_t childPid;
goto exit;
if (childHandle == NULL)
{
fprintf(stderr, "Could not create a child process!\n");
}
if (childPid == -1)
fprintf(stderr, "Could not retrieve the PID!\n");
else
printf("The child process has PID:%u\n", (unsigned int)childPid);
return EXIT_SUCCESS;
exit:
return EXIT_FAILURE;
}