1 | /* $Id: close.c,v 1.1.1.2 2004-10-03 04:58:49 ghudson Exp $ */ |
---|
2 | |
---|
3 | /* Copyright (C) 1998-99 Martin Baulig |
---|
4 | This file is part of LibGTop 1.0. |
---|
5 | |
---|
6 | Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. |
---|
7 | |
---|
8 | LibGTop is free software; you can redistribute it and/or modify it |
---|
9 | under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2 of the License, |
---|
11 | or (at your option) any later version. |
---|
12 | |
---|
13 | LibGTop is distributed in the hope that it will be useful, but WITHOUT |
---|
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
16 | for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with LibGTop; see the file COPYING. If not, write to the |
---|
20 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #include <glibtop.h> |
---|
25 | #include <glibtop/open.h> |
---|
26 | #include <glibtop/close.h> |
---|
27 | #include <glibtop/command.h> |
---|
28 | |
---|
29 | /* Closes server. */ |
---|
30 | |
---|
31 | void |
---|
32 | glibtop_close_r (glibtop *server) |
---|
33 | { |
---|
34 | switch (server->method) { |
---|
35 | case GLIBTOP_METHOD_UNIX: |
---|
36 | case GLIBTOP_METHOD_INET: |
---|
37 | glibtop_call_l (server, GLIBTOP_CMND_QUIT, |
---|
38 | 0, NULL, 0, NULL); |
---|
39 | |
---|
40 | if (close (server->socket)) |
---|
41 | glibtop_warn_io ("close"); |
---|
42 | |
---|
43 | break; |
---|
44 | case GLIBTOP_METHOD_PIPE: |
---|
45 | kill (server->pid, SIGKILL); |
---|
46 | close (server->input [0]); |
---|
47 | close (server->output [1]); |
---|
48 | break; |
---|
49 | } |
---|
50 | } |
---|