GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
shutdown.c
Go to the documentation of this file.
1 
15 #include <stdlib.h>
16 
17 #include <grass/dbmi.h>
18 #include <grass/spawn.h>
19 #include "macros.h"
20 
36 int db_shutdown_driver(dbDriver * driver)
37 {
38  int status;
39 
40 #ifdef __MINGW32__
41  db__set_protocol_fds(driver->send, driver->recv);
42  DB_START_PROCEDURE_CALL(DB_PROC_SHUTDOWN_DRIVER);
43 #endif
44 
45  /* close the communication FILEs */
46  fclose(driver->send);
47  fclose(driver->recv);
48 
49  driver->send = NULL;
50  driver->recv = NULL;
51 
52  /* wait for the driver to finish */
53  status = -1;
54 
55  /* convert status according to return code of G_wait() */
56  status = G_wait(driver->pid) == -1 ? -1 : 0;
57 
58  driver->pid = 0;
59 
60  /* free the driver structure. THIS IS GOOFY */
61  db_free(driver);
62 
63  return status;
64 }
int G_wait(int i_pid)
Definition: spawn.c:955
void db__set_protocol_fds(FILE *send, FILE *recv)
Definition: xdr.c:71
int db_shutdown_driver(dbDriver *driver)
Closedown the driver, and free the driver structure.
Definition: shutdown.c:36
#define DB_START_PROCEDURE_CALL(x)
Definition: macros.h:2
return NULL
Definition: dbfopen.c:1394
Definition: driver.h:25
fclose(fd)
void db_free(void *s)