GRASS 8 Programmer's Manual 8.6.0dev(2026)-1878fdfec5
Loading...
Searching...
No Matches
shutdown.c
Go to the documentation of this file.
1/*!
2 * \file db/dbmi_client/shutdown.c
3 *
4 * \brief DBMI Library (client) - shutdown database connection
5 *
6 * SPDX-FileCopyrightText: 1999-2008 GRASS Development Team
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * \author Joel Jones (CERL/UIUC), Radim Blazek
10 */
11
12#include <stdlib.h>
13
14#include <grass/dbmi.h>
15#include <grass/spawn.h>
16#include "macros.h"
17
18/*!
19 \brief Closedown the driver, and free the driver structure
20
21 <b>Note:</b> the management of the memory for the driver structure
22 probably should be handled differently.
23
24 db_start_driver() could take a pointer to driver structure as an
25 argument, instead of returning the pointer to allocated then there
26 would be no hidden free required
27
28 \param driver pointer to dbDriver to be freed
29
30 \return 0 on success
31 \return -1 on error
32 */
34{
35 int status;
36
39
40 /* close the communication FILEs */
41 fclose(driver->send);
42 fclose(driver->recv);
43
44 driver->send = NULL;
45 driver->recv = NULL;
46
47 /* wait for the driver to finish */
48 status = -1;
49
50 /* convert status according to return code of G_wait() */
51 status = G_wait(driver->pid) == -1 ? -1 : 0;
52
53 driver->pid = 0;
54
55 /* remove also error handler if defined */
57
58 /* free the driver structure. THIS IS GOOFY */
60
61 return status;
62}
#define NULL
Definition ccmath.h:32
Main header of GRASS DataBase Management Interface.
#define DB_PROC_SHUTDOWN_DRIVER
Definition dbmi.h:33
void db_free(void *)
Free allocated memory.
void db__set_protocol_fds(FILE *, FILE *)
?
void db_unset_error_handler_driver(dbDriver *)
Remove error handler before closing the driver.
int G_wait(int i_pid)
Definition spawn.c:948
#define DB_START_PROCEDURE_CALL(x)
Definition macros.h:2
int db_shutdown_driver(dbDriver *driver)
Closedown the driver, and free the driver structure.
Definition shutdown.c:33