BRL-CAD
kill.c
Go to the documentation of this file.
1 /* K I L L . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2007-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #include "common.h"
22 
23 /* system headers */
24 #include <signal.h>
25 #include "bio.h"
26 
27 /* bu headers */
28 #include "bu/parallel.h"
29 
30 /* c99 doesn't declare these */
31 #if defined(HAVE_KILL) && !defined(__cplusplus)
32 extern int kill(pid_t, int);
33 #endif
34 
35 
36 int
37 bu_terminate(int process)
38 {
39  int successful = 0;
40 
41 #ifdef HAVE_KILL
42  /* kill() returns 0 for success */
43  successful = kill(process, SIGKILL);
44  successful = !successful;
45 #else
46  HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, (DWORD)process);
47  if (hProcess != NULL) {
48  successful = TerminateProcess(hProcess, 0);
49  }
50 #endif
51 
52  return successful;
53 }
54 
55 /*
56  * Local Variables:
57  * tab-width: 8
58  * mode: C
59  * indent-tabs-mode: t
60  * c-file-style: "stroustrup"
61  * End:
62  * ex: shiftwidth=4 tabstop=8
63  */
Header file for the BRL-CAD common definitions.
int bu_terminate(int process)
Definition: kill.c:37
#define TRUE