Mercurial > hg > freeDiameter
changeset 985:74a5e2b8ae19
Make sure dbg_interactive is linked with a console for running. Use printf in that case
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Sun, 17 Mar 2013 13:45:00 +0100 |
parents | 98f43c0ddfa4 |
children | 46c675a28e40 |
files | extensions/dbg_interactive/dbg_interactive.c |
diffstat | 1 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/dbg_interactive/dbg_interactive.c Sat Mar 16 16:23:44 2013 +0100 +++ b/extensions/dbg_interactive/dbg_interactive.c Sun Mar 17 13:45:00 2013 +0100 @@ -35,6 +35,7 @@ #include <Python.h> #include <freeDiameter/extension.h> +#include <unistd.h> /* wrapper generated by SWIG */ #if PY_VERSION_HEX >= 0x03000000 @@ -60,13 +61,20 @@ CHECK_FCT_DO(fd_core_waitstartcomplete(), goto end); - fd_log_debug("Starting interactive python interpreter [experimental]."); - if (!arg) { - fd_log_debug("Example syntax:"); - fd_log_debug(" >>> print cvar.fd_g_config.cnf_diamid"); - fd_log_debug(" '%s'", fd_g_config->cnf_diamid); + if (arg) { + fd_log_debug("Starting python interpreter with a script file [experimental]."); + Py_Main(2, dum); + } else { + if (!isatty(fileno(stdin)) || !isatty(fileno(stdout))) { + TRACE_ERROR("[dbg_interactive]: this extension requires freeDiameter to be run from a console terminal!"); + goto end; + } + printf("Starting interactive python interpreter [experimental].\n"); + printf("Example syntax:\n"); + printf(" >>> print cvar.fd_g_config.cnf_diamid\n"); + printf(" '%s'\n", fd_g_config->cnf_diamid); + Py_Main(1, dum); } - Py_Main(arg ? 2 : 1, dum); end: /* Upon exit, issue the order of terminating to fD, if the interpreter was started without a file */