1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #if HAVE_FORK && HAVE_EXECLP
23 #include <sys/types.h>
29 /* Fork, start gdb and connect to the parent process.
30 If that happens successfully, then this function does not return,
31 but exits with EXIT_FAILURE. Otherwise it returns.
34 connect_debugger (void)
39 snprintf (pidstr, 20, "%d", getpid ());
43 perror ("Cannot fork");
49 execlp ("gdb", "gdb", "-p", pidstr, NULL);
50 perror ("Cannot exec debugger");
57 if ( EXIT_SUCCESS != WEXITSTATUS (status) )
64 #else /* !(HAVE_FORK && HAVE_EXECLP) */
65 /* Don't know how to connect to gdb.
69 connect_debugger (void)
72 #endif /* !(HAVE_FORK && HAVE_EXECLP) */