Re: [E-devel] [PATCH] ecore pipe add close functions

2009-04-22 Thread The Rasterman
On Wed, 25 Mar 2009 08:53:41 +0100 l...@segv.dk (Lars Munch) said:

patch in! (sorry - i miss these - if you inline paste a patch as opposed to
attach it.. the little there is an attachment icon doesnt show up for that
mail).

 Hi
 
 This patch adds two new functions, ecore_pipe_close_read and
 ecore_pipe_close_write, to ecore_pipe. The purpose it to enable
 ecore_pipe to be used together with fork (see example below).
 
 The patch also handles if the read or write end of the pipe closes.
 
 /*
   Test example
   gcc -Wall `pkg-config --libs --cflags ecore` tstpipe.c -o tstpipe
 */
 
 void handler(void *data, void *buffer, unsigned int nbyte)
 {
char *s;
fprintf(stderr, length %d\n, nbyte);
if(nbyte  0 || buffer != NULL)
  {
   s = strndup((char*) buffer, nbyte);
   fprintf(stderr, %s\n, s);
   free(s);
  }
else
  ecore_main_loop_quit();
 }
 
 int main(int argc, char *argv[])
 {
Ecore_Pipe *p;
pid_t cpid;
 
ecore_init();
p = ecore_pipe_add(handler, NULL);
 
cpid = fork();
if (cpid == -1)
  {
   perror(fork);
   exit(EXIT_FAILURE);
  }
 
if (cpid == 0)
  {
   int i;
   /* Child */
   ecore_pipe_close_read(p);
   for(i=0; i4; i++) {
  if(!ecore_pipe_write(p, 0123456789, 10))
exit(EXIT_SUCCESS);
  sleep(1);
   }
   exit(EXIT_SUCCESS);
  }
else
  {
   /* Parent */
   ecore_pipe_close_write(p);
   ecore_main_loop_begin();
   exit(EXIT_SUCCESS);
  }
 
ecore_shutdown();
 }
 
 Signed-off-by: Lars Munch l...@segv.dk
 ---
  src/lib/ecore/Ecore.h  |4 +-
  src/lib/ecore/ecore_pipe.c |  101 ++
 +- 2 files changed, 93 insertions(+), 12 deletions(-)
 
 diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h
 index 0a1969d..0277852 100644
 --- a/src/lib/ecore/Ecore.h
 +++ b/src/lib/ecore/Ecore.h
 @@ -290,10 +290,12 @@ extern C {
 EAPI Ecore_Pipe  *ecore_pipe_add(void (*handler) (void *data, void
 *buffer, unsigned int nbyte), const void *data); EAPI void
 *ecore_pipe_del(Ecore_Pipe *p); EAPI int  ecore_pipe_write(Ecore_Pipe
 *p, const void *buffer, unsigned int nbytes);
 +   EAPI void ecore_pipe_close_write(Ecore_Pipe *p);
 +   EAPI void ecore_pipe_close_read(Ecore_Pipe *p);
  
 EAPI double ecore_time_get(void);
 EAPI double ecore_loop_time_get(void);
 -   
 +
 EAPI Ecore_Timer *ecore_timer_add(double in, int (*func) (void *data),
 const void *data); EAPI Ecore_Timer *ecore_timer_loop_add(double in, int
 (*func) (void *data), const void *data); EAPI void*ecore_timer_del
 (Ecore_Timer *timer); diff --git a/src/lib/ecore/ecore_pipe.c
 b/src/lib/ecore/ecore_pipe.c index f6e4778..5608eda 100644
 --- a/src/lib/ecore/ecore_pipe.c
 +++ b/src/lib/ecore/ecore_pipe.c
 @@ -332,20 +332,68 @@ ecore_pipe_del(Ecore_Pipe *p)
 ecore_pipe_del);
   return NULL;
   }
 -   ecore_main_fd_handler_del(p-fd_handler);
 -   close(p-fd_read);
 -   close(p-fd_write);
 +   if(p-fd_handler != NULL)
 + ecore_main_fd_handler_del(p-fd_handler);
 +   if(p-fd_read != -1)
 + close(p-fd_read);
 +   if(p-fd_write != -1)
 + close(p-fd_write);
 data = (void *)p-data;
 free (p);
 return data;
  }
  
  /**
 + * Close the read end of an Ecore_Pipe object created with ecore_pipe_add().
 + *
 + * @param p The Ecore_Pipe object.
 + * @ingroup Ecore_Pipe_Group
 + */
 +EAPI void
 +ecore_pipe_close_read(Ecore_Pipe *p)
 +{
 +   void *data;
 +
 +   if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
 + {
 + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
 +   ecore_pipe_close_read);
 + return;
 + }
 +   ecore_main_fd_handler_del(p-fd_handler);
 +   p-fd_handler = NULL;
 +   close(p-fd_read);
 +   p-fd_read = -1;
 +}
 +
 +/**
 + * Close the write end of an Ecore_Pipe object created with ecore_pipe_add().
 + *
 + * @param p The Ecore_Pipe object.
 + * @ingroup Ecore_Pipe_Group
 + */
 +EAPI void
 +ecore_pipe_close_write(Ecore_Pipe *p)
 +{
 +   void *data;
 +
 +   if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
 + {
 + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
 +   ecore_pipe_close_write);
 + return;
 + }
 +   close(p-fd_write);
 +   p-fd_write = -1;
 +}
 +
 +/**
   * Write on the file descriptor the data passed as parameter.
   *
   * @param p  The Ecore_Pipe object.
   * @param buffer The data to write into the pipe.
   * @param nbytes The size of the @p buffer in bytes
 + * @return   Returns TRUE on a successful write, FALSE on an error
   * @ingroup Ecore_Pipe_Group
   */
  EAPI int
 @@ -359,9 +407,13 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer,
 unsigned int nbytes) {
   ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
 ecore_pipe_write);
 - return 0;
 + return FALSE;
   }
 -   /* first write the len into the pipe */
 +
 +   if(p-fd_write == -1)
 + return FALSE;
 +
 +   /* First write the len 

Re: [E-devel] [PATCH] ecore pipe add close functions

2009-04-21 Thread Sachiel
On Mon, Apr 20, 2009 at 9:21 AM, Peter Wehrfritz peter.wehrfr...@web.de wrote:
 Gustavo Sverzut Barbieri schrieb:
 was this ever committed? should it be? It was marked as pending in my list.


 Afaik, it wasn't committed. I think it looks reasonable, but I haven't
 actually tested it. I hoped someone how is more familar then me with
 pipes and forking is going to review it, and than I forgot about it.

 Peter


Patch looks good to me, but I can't test or commit now. If someone else
wants to and no one objects, go ahead.

 --
 Stay on top of everything new and different, both inside and
 around Java (TM) technology - register by April 22, and save
 $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
 300 plus technical and hands-on sessions. Register today.
 Use priority code J9JMT32. http://p.sf.net/sfu/p
 ___
 enlightenment-devel mailing list
 enlightenment-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


--
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [PATCH] ecore pipe add close functions

2009-04-19 Thread Gustavo Sverzut Barbieri
was this ever committed? should it be? It was marked as pending in my list.

On Wed, Mar 25, 2009 at 5:37 AM, Lars Munch l...@segv.dk wrote:
 On Wed, Mar 25, 2009 at 09:08:53AM +0100, Peter Wehrfritz wrote:
 Lars Munch schrieb:
 Hi
 
 This patch adds two new functions, ecore_pipe_close_read and
 ecore_pipe_close_write, to ecore_pipe. The purpose it to enable
 ecore_pipe to be used together with fork (see example below).
 
 The patch also handles if the read or write end of the pipe closes.
 

 I think the names don't fit in to the efl-naming schema, very well. That
 means that the verb is at the end of the function name, here this would
 be close. So ecore_pipe_write_close, or ecore_pipe_write_end_close
 would be better.

 Yes, you are right. Updated patch below.

 This patch adds two new functions, ecore_pipe_read_close and
 ecore_pipe_write_close, to ecore_pipe. The purpose it to enable
 ecore_pipe to be used together with fork.

 The patch also handles if the read or write end of the pipe closes.

 Signed-off-by: Lars Munch l...@segv.dk
 ---
  src/lib/ecore/Ecore.h      |    4 +-
  src/lib/ecore/ecore_pipe.c |  101 
 +++-
  2 files changed, 93 insertions(+), 12 deletions(-)

 diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h
 index 0a1969d..b001ded 100644
 --- a/src/lib/ecore/Ecore.h
 +++ b/src/lib/ecore/Ecore.h
 @@ -290,10 +290,12 @@ extern C {
    EAPI Ecore_Pipe  *ecore_pipe_add(void (*handler) (void *data, void 
 *buffer, unsigned int nbyte), const void *data);
    EAPI void        *ecore_pipe_del(Ecore_Pipe *p);
    EAPI int          ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
 unsigned int nbytes);
 +   EAPI void         ecore_pipe_write_close(Ecore_Pipe *p);
 +   EAPI void         ecore_pipe_read_close(Ecore_Pipe *p);

    EAPI double ecore_time_get(void);
    EAPI double ecore_loop_time_get(void);
 -
 +
    EAPI Ecore_Timer *ecore_timer_add(double in, int (*func) (void *data), 
 const void *data);
    EAPI Ecore_Timer *ecore_timer_loop_add(double in, int (*func) (void 
 *data), const void *data);
    EAPI void        *ecore_timer_del(Ecore_Timer *timer);
 diff --git a/src/lib/ecore/ecore_pipe.c b/src/lib/ecore/ecore_pipe.c
 index f6e4778..84fded0 100644
 --- a/src/lib/ecore/ecore_pipe.c
 +++ b/src/lib/ecore/ecore_pipe.c
 @@ -332,20 +332,68 @@ ecore_pipe_del(Ecore_Pipe *p)
              ecore_pipe_del);
        return NULL;
      }
 -   ecore_main_fd_handler_del(p-fd_handler);
 -   close(p-fd_read);
 -   close(p-fd_write);
 +   if(p-fd_handler != NULL)
 +     ecore_main_fd_handler_del(p-fd_handler);
 +   if(p-fd_read != -1)
 +     close(p-fd_read);
 +   if(p-fd_write != -1)
 +     close(p-fd_write);
    data = (void *)p-data;
    free (p);
    return data;
  }

  /**
 + * Close the read end of an Ecore_Pipe object created with ecore_pipe_add().
 + *
 + * @param p The Ecore_Pipe object.
 + * @ingroup Ecore_Pipe_Group
 + */
 +EAPI void
 +ecore_pipe_read_close(Ecore_Pipe *p)
 +{
 +   void *data;
 +
 +   if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
 +     {
 +       ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
 +             ecore_pipe_close_read);
 +       return;
 +     }
 +   ecore_main_fd_handler_del(p-fd_handler);
 +   p-fd_handler = NULL;
 +   close(p-fd_read);
 +   p-fd_read = -1;
 +}
 +
 +/**
 + * Close the write end of an Ecore_Pipe object created with ecore_pipe_add().
 + *
 + * @param p The Ecore_Pipe object.
 + * @ingroup Ecore_Pipe_Group
 + */
 +EAPI void
 +ecore_pipe_write_close(Ecore_Pipe *p)
 +{
 +   void *data;
 +
 +   if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
 +     {
 +       ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
 +             ecore_pipe_close_write);
 +       return;
 +     }
 +   close(p-fd_write);
 +   p-fd_write = -1;
 +}
 +
 +/**
  * Write on the file descriptor the data passed as parameter.
  *
  * @param p      The Ecore_Pipe object.
  * @param buffer The data to write into the pipe.
  * @param nbytes The size of the @p buffer in bytes
 + * @return       Returns TRUE on a successful write, FALSE on an error
  * @ingroup Ecore_Pipe_Group
  */
  EAPI int
 @@ -359,9 +407,13 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
 unsigned int nbytes)
      {
        ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
              ecore_pipe_write);
 -       return 0;
 +       return FALSE;
      }
 -   /* first write the len into the pipe */
 +
 +   if(p-fd_write == -1)
 +     return FALSE;
 +
 +   /* First write the len into the pipe */
    do
      {
        ret = pipe_write(p-fd_write, nbytes, sizeof(nbytes));
 @@ -375,7 +427,13 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
 unsigned int nbytes)
             /* XXX What should we do here? */
             fprintf(stderr, The length of the data was not written complete
                   to the pipe\n);
 -            return 0;
 +            return FALSE;
 +         }
 +       else if (ret == -1  errno == EPIPE)
 +         {
 +            close(p-fd_write);
 +            

[E-devel] [PATCH] ecore pipe add close functions

2009-03-25 Thread Lars Munch
Hi

This patch adds two new functions, ecore_pipe_close_read and
ecore_pipe_close_write, to ecore_pipe. The purpose it to enable
ecore_pipe to be used together with fork (see example below).

The patch also handles if the read or write end of the pipe closes.

/*
  Test example
  gcc -Wall `pkg-config --libs --cflags ecore` tstpipe.c -o tstpipe
*/

void handler(void *data, void *buffer, unsigned int nbyte)
{
   char *s;
   fprintf(stderr, length %d\n, nbyte);
   if(nbyte  0 || buffer != NULL)
 {
s = strndup((char*) buffer, nbyte);
fprintf(stderr, %s\n, s);
free(s);
 }
   else
 ecore_main_loop_quit();
}

int main(int argc, char *argv[])
{
   Ecore_Pipe *p;
   pid_t cpid;

   ecore_init();
   p = ecore_pipe_add(handler, NULL);

   cpid = fork();
   if (cpid == -1)
 {
perror(fork);
exit(EXIT_FAILURE);
 }

   if (cpid == 0)
 {
int i;
/* Child */
ecore_pipe_close_read(p);
for(i=0; i4; i++) {
   if(!ecore_pipe_write(p, 0123456789, 10))
 exit(EXIT_SUCCESS);
   sleep(1);
}
exit(EXIT_SUCCESS);
 }
   else
 {
/* Parent */
ecore_pipe_close_write(p);
ecore_main_loop_begin();
exit(EXIT_SUCCESS);
 }

   ecore_shutdown();
}

Signed-off-by: Lars Munch l...@segv.dk
---
 src/lib/ecore/Ecore.h  |4 +-
 src/lib/ecore/ecore_pipe.c |  101 +++-
 2 files changed, 93 insertions(+), 12 deletions(-)

diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h
index 0a1969d..0277852 100644
--- a/src/lib/ecore/Ecore.h
+++ b/src/lib/ecore/Ecore.h
@@ -290,10 +290,12 @@ extern C {
EAPI Ecore_Pipe  *ecore_pipe_add(void (*handler) (void *data, void *buffer, 
unsigned int nbyte), const void *data);
EAPI void*ecore_pipe_del(Ecore_Pipe *p);
EAPI int  ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
unsigned int nbytes);
+   EAPI void ecore_pipe_close_write(Ecore_Pipe *p);
+   EAPI void ecore_pipe_close_read(Ecore_Pipe *p);
 
EAPI double ecore_time_get(void);
EAPI double ecore_loop_time_get(void);
-   
+
EAPI Ecore_Timer *ecore_timer_add(double in, int (*func) (void *data), 
const void *data);
EAPI Ecore_Timer *ecore_timer_loop_add(double in, int (*func) (void *data), 
const void *data);
EAPI void*ecore_timer_del(Ecore_Timer *timer);
diff --git a/src/lib/ecore/ecore_pipe.c b/src/lib/ecore/ecore_pipe.c
index f6e4778..5608eda 100644
--- a/src/lib/ecore/ecore_pipe.c
+++ b/src/lib/ecore/ecore_pipe.c
@@ -332,20 +332,68 @@ ecore_pipe_del(Ecore_Pipe *p)
  ecore_pipe_del);
return NULL;
  }
-   ecore_main_fd_handler_del(p-fd_handler);
-   close(p-fd_read);
-   close(p-fd_write);
+   if(p-fd_handler != NULL)
+ ecore_main_fd_handler_del(p-fd_handler);
+   if(p-fd_read != -1)
+ close(p-fd_read);
+   if(p-fd_write != -1)
+ close(p-fd_write);
data = (void *)p-data;
free (p);
return data;
 }
 
 /**
+ * Close the read end of an Ecore_Pipe object created with ecore_pipe_add().
+ *
+ * @param p The Ecore_Pipe object.
+ * @ingroup Ecore_Pipe_Group
+ */
+EAPI void
+ecore_pipe_close_read(Ecore_Pipe *p)
+{
+   void *data;
+
+   if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
+ {
+   ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
+ ecore_pipe_close_read);
+   return;
+ }
+   ecore_main_fd_handler_del(p-fd_handler);
+   p-fd_handler = NULL;
+   close(p-fd_read);
+   p-fd_read = -1;
+}
+
+/**
+ * Close the write end of an Ecore_Pipe object created with ecore_pipe_add().
+ *
+ * @param p The Ecore_Pipe object.
+ * @ingroup Ecore_Pipe_Group
+ */
+EAPI void
+ecore_pipe_close_write(Ecore_Pipe *p)
+{
+   void *data;
+
+   if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
+ {
+   ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
+ ecore_pipe_close_write);
+   return;
+ }
+   close(p-fd_write);
+   p-fd_write = -1;
+}
+
+/**
  * Write on the file descriptor the data passed as parameter.
  *
  * @param p  The Ecore_Pipe object.
  * @param buffer The data to write into the pipe.
  * @param nbytes The size of the @p buffer in bytes
+ * @return   Returns TRUE on a successful write, FALSE on an error
  * @ingroup Ecore_Pipe_Group
  */
 EAPI int
@@ -359,9 +407,13 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
unsigned int nbytes)
  {
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
  ecore_pipe_write);
-   return 0;
+   return FALSE;
  }
-   /* first write the len into the pipe */
+
+   if(p-fd_write == -1)
+ return FALSE;
+
+   /* First write the len into the pipe */
do
  {
ret = pipe_write(p-fd_write, nbytes, sizeof(nbytes));
@@ -375,7 +427,13 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
unsigned int nbytes)
 /* XXX What should we do here? */
 fprintf(stderr, The length of the data was not written complete

Re: [E-devel] [PATCH] ecore pipe add close functions

2009-03-25 Thread Lars Munch
On Wed, Mar 25, 2009 at 09:08:53AM +0100, Peter Wehrfritz wrote:
 Lars Munch schrieb:
 Hi
 
 This patch adds two new functions, ecore_pipe_close_read and
 ecore_pipe_close_write, to ecore_pipe. The purpose it to enable
 ecore_pipe to be used together with fork (see example below).
 
 The patch also handles if the read or write end of the pipe closes.
   
 
 I think the names don't fit in to the efl-naming schema, very well. That 
 means that the verb is at the end of the function name, here this would 
 be close. So ecore_pipe_write_close, or ecore_pipe_write_end_close 
 would be better.

Yes, you are right. Updated patch below.

This patch adds two new functions, ecore_pipe_read_close and
ecore_pipe_write_close, to ecore_pipe. The purpose it to enable
ecore_pipe to be used together with fork.

The patch also handles if the read or write end of the pipe closes.

Signed-off-by: Lars Munch l...@segv.dk
---
 src/lib/ecore/Ecore.h  |4 +-
 src/lib/ecore/ecore_pipe.c |  101 +++-
 2 files changed, 93 insertions(+), 12 deletions(-)

diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h
index 0a1969d..b001ded 100644
--- a/src/lib/ecore/Ecore.h
+++ b/src/lib/ecore/Ecore.h
@@ -290,10 +290,12 @@ extern C {
EAPI Ecore_Pipe  *ecore_pipe_add(void (*handler) (void *data, void *buffer, 
unsigned int nbyte), const void *data);
EAPI void*ecore_pipe_del(Ecore_Pipe *p);
EAPI int  ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
unsigned int nbytes);
+   EAPI void ecore_pipe_write_close(Ecore_Pipe *p);
+   EAPI void ecore_pipe_read_close(Ecore_Pipe *p);
 
EAPI double ecore_time_get(void);
EAPI double ecore_loop_time_get(void);
-   
+
EAPI Ecore_Timer *ecore_timer_add(double in, int (*func) (void *data), 
const void *data);
EAPI Ecore_Timer *ecore_timer_loop_add(double in, int (*func) (void *data), 
const void *data);
EAPI void*ecore_timer_del(Ecore_Timer *timer);
diff --git a/src/lib/ecore/ecore_pipe.c b/src/lib/ecore/ecore_pipe.c
index f6e4778..84fded0 100644
--- a/src/lib/ecore/ecore_pipe.c
+++ b/src/lib/ecore/ecore_pipe.c
@@ -332,20 +332,68 @@ ecore_pipe_del(Ecore_Pipe *p)
  ecore_pipe_del);
return NULL;
  }
-   ecore_main_fd_handler_del(p-fd_handler);
-   close(p-fd_read);
-   close(p-fd_write);
+   if(p-fd_handler != NULL)
+ ecore_main_fd_handler_del(p-fd_handler);
+   if(p-fd_read != -1)
+ close(p-fd_read);
+   if(p-fd_write != -1)
+ close(p-fd_write);
data = (void *)p-data;
free (p);
return data;
 }
 
 /**
+ * Close the read end of an Ecore_Pipe object created with ecore_pipe_add().
+ *
+ * @param p The Ecore_Pipe object.
+ * @ingroup Ecore_Pipe_Group
+ */
+EAPI void
+ecore_pipe_read_close(Ecore_Pipe *p)
+{
+   void *data;
+
+   if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
+ {
+   ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
+ ecore_pipe_close_read);
+   return;
+ }
+   ecore_main_fd_handler_del(p-fd_handler);
+   p-fd_handler = NULL;
+   close(p-fd_read);
+   p-fd_read = -1;
+}
+
+/**
+ * Close the write end of an Ecore_Pipe object created with ecore_pipe_add().
+ *
+ * @param p The Ecore_Pipe object.
+ * @ingroup Ecore_Pipe_Group
+ */
+EAPI void
+ecore_pipe_write_close(Ecore_Pipe *p)
+{
+   void *data;
+
+   if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE))
+ {
+   ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
+ ecore_pipe_close_write);
+   return;
+ }
+   close(p-fd_write);
+   p-fd_write = -1;
+}
+
+/**
  * Write on the file descriptor the data passed as parameter.
  *
  * @param p  The Ecore_Pipe object.
  * @param buffer The data to write into the pipe.
  * @param nbytes The size of the @p buffer in bytes
+ * @return   Returns TRUE on a successful write, FALSE on an error
  * @ingroup Ecore_Pipe_Group
  */
 EAPI int
@@ -359,9 +407,13 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
unsigned int nbytes)
  {
ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE,
  ecore_pipe_write);
-   return 0;
+   return FALSE;
  }
-   /* first write the len into the pipe */
+
+   if(p-fd_write == -1)
+ return FALSE;
+
+   /* First write the len into the pipe */
do
  {
ret = pipe_write(p-fd_write, nbytes, sizeof(nbytes));
@@ -375,7 +427,13 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
unsigned int nbytes)
 /* XXX What should we do here? */
 fprintf(stderr, The length of the data was not written complete
   to the pipe\n);
-return 0;
+return FALSE;
+ }
+   else if (ret == -1  errno == EPIPE)
+ {
+close(p-fd_write);
+p-fd_write = -1;
+return FALSE;
  }
else if (ret == -1  errno == EINTR)
  /* try it again */
@@ -390,7 +448,7 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, 
unsigned int nbytes)
while