# HG changeset patch # User Sebastien Decugis # Date 1363524300 -3600 # Node ID 74a5e2b8ae19939c315b2666c27c9c5551f4e06f # Parent 98f43c0ddfa42697aba4c5c19ffd6e2522cd317e Make sure dbg_interactive is linked with a console for running. Use printf in that case diff -r 98f43c0ddfa4 -r 74a5e2b8ae19 extensions/dbg_interactive/dbg_interactive.c --- 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 #include +#include /* 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 */