X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=lib%2Fwrappi.c;h=6c31c701b3a68e495b2c8b651066d4e7da0ec59b;hb=cf654cde5cfc9337e254934b23274e4a7b3432ba;hp=0e4589037d269e88c5951e5ffadbdc8a444cf6f9;hpb=53126578ee08c0bd3b3987959fb7d768deb5aedc;p=wrappi.git diff --git a/lib/wrappi.c b/lib/wrappi.c index 0e45890..6c31c70 100644 --- a/lib/wrappi.c +++ b/lib/wrappi.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "wrappi.h" #include "internal.h" @@ -32,12 +34,25 @@ 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->wrappid_path); free (w); } @@ -98,3 +113,15 @@ wrap_int_set_error_errno (struct wrap_internal_h *w, set_error_buf (w, msg, errnum, func); } + +/* Note the gperf perfect hash in lib/internal-procs-lookup.gperf */ +int +wrap_int_lookup_proc_entry (const char *name) +{ + const struct proc_entry *v = + wrap_int_gperf_lookup_proc_entry (name, strlen (name)); + if (v) + return v->proc_nr; + else + return -1; +}