GRASS Programmer's Manual  6.4.2(2012)
shutdown.c
Go to the documentation of this file.
00001 
00015 #include <stdlib.h>
00016 
00017 #include <grass/dbmi.h>
00018 #include <grass/spawn.h>
00019 #include "macros.h"
00020 
00036 int db_shutdown_driver(dbDriver * driver)
00037 {
00038     int status;
00039 
00040 #ifdef __MINGW32__
00041     db__set_protocol_fds(driver->send, driver->recv);
00042     DB_START_PROCEDURE_CALL(DB_PROC_SHUTDOWN_DRIVER);
00043 #endif
00044 
00045     /* close the communication FILEs */
00046     fclose(driver->send);
00047     fclose(driver->recv);
00048 
00049     driver->send = NULL;
00050     driver->recv = NULL;
00051 
00052     /* wait for the driver to finish */
00053     status = -1;
00054 
00055     /* convert status according to return code of G_wait() */
00056     status = G_wait(driver->pid) == -1 ? -1 : 0;
00057 
00058     driver->pid = 0;
00059 
00060     /* free the driver structure. THIS IS GOOFY */
00061     db_free(driver);
00062 
00063     return status;
00064 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines