xref: /netbsd-src/external/ibm-public/postfix/dist/src/global/debug_process.c (revision 41fbaed053f8fbfdf9d2a4ee0a7386a3c83f8505)
1 /*	$NetBSD: debug_process.c,v 1.1.1.1 2009/06/23 10:08:45 tron Exp $	*/
2 
3 /*++
4 /* NAME
5 /*	debug_process 3
6 /* SUMMARY
7 /*	run an external debugger
8 /* SYNOPSIS
9 /*	#include <debug_process.h>
10 /*
11 /*	char	*debug_process()
12 /* DESCRIPTION
13 /*	debug_process() runs a debugger, as specified in the
14 /*	\fIdebugger_command\fR configuration variable.
15 /*
16 /*	Examples of non-interactive debuggers are call tracing tools
17 /*	such as: trace, strace or truss.
18 /*
19 /*	Examples of interactive debuggers are xxgdb, xxdbx, and so on.
20 /*	In order to use an X-based debugger, the process must have a
21 /*	properly set up XAUTHORITY environment variable.
22 /* LICENSE
23 /* .ad
24 /* .fi
25 /*	The Secure Mailer license must be distributed with this software.
26 /* AUTHOR(S)
27 /*	Wietse Venema
28 /*	IBM T.J. Watson Research
29 /*	P.O. Box 704
30 /*	Yorktown Heights, NY 10598, USA
31 /*--*/
32 
33 /* System library. */
34 
35 #include <sys_defs.h>
36 #include <string.h>
37 #include <stdlib.h>
38 #include <unistd.h>
39 
40 /* Utility library. */
41 
42 #include <msg.h>
43 
44 /* Global library. */
45 
46 #include "mail_params.h"
47 #include "mail_conf.h"
48 #include "debug_process.h"
49 
50 /* debug_process - run a debugger on this process */
51 
debug_process(void)52 void    debug_process(void)
53 {
54     const char *command;
55 
56     /*
57      * Expand $debugger_command then run it.
58      */
59     command = mail_conf_lookup_eval(VAR_DEBUG_COMMAND);
60     if (command == 0 || *command == 0)
61 	msg_fatal("no %s variable set up", VAR_DEBUG_COMMAND);
62     msg_info("running: %s", command);
63     system(command);
64 }
65