X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fguestfs.c;h=f445adabcf073bb455517cb71470eae4eb7c4bcc;hb=4c54721ad46b77c52eb6bb7e3ffe74325ac52797;hp=66ab12af0438960f63bd597a5cd2c2eb3992e8f6;hpb=d5532e9ad29b28c2b323ad0abe4e0caa6e03f675;p=libguestfs.git diff --git a/src/guestfs.c b/src/guestfs.c index 66ab12a..f445ada 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -327,6 +327,25 @@ guestfs_close (guestfs_h *g) if (g->state != CONFIG) guestfs_kill_subprocess (g); + /* Close any sockets and deregister any handlers. */ + if (g->stdout_watch >= 0) + g->main_loop->remove_handle (g->main_loop, g, g->stdout_watch); + if (g->sock_watch >= 0) + g->main_loop->remove_handle (g->main_loop, g, g->sock_watch); + g->stdout_watch = -1; + g->sock_watch = -1; + + if (g->fd[0] >= 0) + close (g->fd[0]); + if (g->fd[1] >= 0) + close (g->fd[1]); + if (g->sock >= 0) + close (g->sock); + g->fd[0] = -1; + g->fd[1] = -1; + g->sock = -1; + + /* Remove tmpfiles. */ if (g->tmpdir) { snprintf (filename, sizeof filename, "%s/sock", g->tmpdir); unlink (filename); @@ -678,6 +697,19 @@ guestfs_get_pid (guestfs_h *g) } } +struct guestfs_version * +guestfs_version (guestfs_h *g) +{ + struct guestfs_version *r; + + r = safe_malloc (g, sizeof *r); + r->major = PACKAGE_VERSION_MAJOR; + r->minor = PACKAGE_VERSION_MINOR; + r->release = PACKAGE_VERSION_RELEASE; + r->extra = safe_strdup (g, PACKAGE_VERSION_EXTRA); + return r; +} + /* Add a string to the current command line. */ static void incr_cmdline_size (guestfs_h *g)