Remote and RPC.
[wrappi.git] / lib / wrappi.c
index 0e45890..c0350f5 100644 (file)
@@ -21,6 +21,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 #include "wrappi.h"
 #include "internal.h"
@@ -32,12 +34,24 @@ wrap_create (void)
   if (w == NULL)
     return NULL;
 
+  w->serial = random ();
+
   return w;
 }
 
 void
 wrap_close (wrap_h *w)
 {
+  if (w->pid)
+    waitpid (w->pid, NULL, 0);
+
+  if (w->rfp != NULL)
+    fclose (w->rfp);
+
+  if (w->wfp != NULL)
+    fclose (w->wfp);
+
+  free (w->hostname);
   free (w);
 }