#include <unistd.h>
#include <Ecore.h>
static void
{
int i, j;
char *buffer;
for (i = 0; i < 20; i++)
{
sleep(1);
buffer = malloc(sizeof(char) * i);
for (j = 0; j < i; j++)
buffer[j] = 'a' + j;
free(buffer);
}
}
static void
handler(
void *data
EINA_UNUSED,
void *buf,
unsigned int len)
{
char *str = malloc(sizeof(char) * len + 1);
memcpy(str, buf, len);
str[len] = '\0';
printf("received %u bytes\n", len);
printf("content: %s\n", (const char *)str);
free(str);
if (len && !strncmp(buf, "close", len < 5 ? len : 5))
{
printf("close requested\n");
}
}
int
main(void)
{
pid_t child_pid;
child_pid = fork();
if (!child_pid)
{
do_lengthy_task(pipe);
}
else
{
}
return 0;
}