Reviewing the sources it would appear that Cint cannot currently be prevented from breaking into its interactive mode if there are issues with the loaded main(). In my situation this prevents Cint from being reliably used to execute remote user supplied scripts. I would prefer to run /bin/cint out of process rather than use the in process API.
The following patch to cint5-5.18.00 adds command line option -o1 (-o being a new generic option) indicating that interactive mode is prohibited during normal script execution (it should not effect debugging).
Only init.cxx is patched and no globals are added or modified.
Perhaps this patch might prove to be a useful option for other Cint users under some circumstances.
--- cint-5.18.00/cint/src/init.cxx 2010-08-17 13:02:16.000000000 +0100
+++ cint/cint/src/init.cxx 2010-08-17 12:13:13.000000000 +0100
@@ -42,6 +42,8 @@
#endif
#endif
+#define G__PROHIBIT_INTERACTION
+
#include "rflx_gendict.h"
//______________________________________________________________________________
@@ -568,6 +570,9 @@
static char clnull[1] = "";
struct G__dictposition stubbegin;
char* icom = 0;
+#ifdef G__PROHIBIT_INTERACTION
+ int prohibitinteraction = 0;
+#endif
/*****************************************************************
* Setting STDIOs. May need to modify here.
* init.c, end.c, scrupto.c, pause.c
@@ -690,9 +695,19 @@
* Get command options
*************************************************************/
char magicchars[100];
- strcpy(magicchars,".:a:b:c:d:ef:gij:kl:mn:pq:rstu:vw:x:y:z:AB:CD:EF:G:H:I:J:L:KM:N:O:P:QRSTU:VW:X:Y:Z:-:@+:");
+ strcpy(magicchars,".:a:b:c:d:ef:gij:kl:mn:o:pq:rstu:vw:x:y:z:AB:CD:EF:G:H:I:J:L:KM:N:O:P:QRSTU:VW:X:Y:Z:-:@+:");
while ((c = getopt(argc, argv, magicchars)) != EOF) {
switch (c) {
+
+#ifdef G__PROHIBIT_INTERACTION
+ // MugginSoft 16/08/10 - option : Interaction with user prohibited
+ case 'o':
+ if ('1' == optarg[0]) {
+ prohibitinteraction = 1;
+ }
+ break;
+#endif
+
#ifndef G__OLDIMPLEMENTATION2226
case '+':
G__setmemtestbreak(atoi(optarg) / 10000, atoi(optarg) % 10000);
@@ -1039,6 +1054,14 @@
icom = optarg;
break;
default:
+
+#ifdef G__PROHIBIT_INTERACTION
+ if (prohibitinteraction ==1) {
+ G__more(G__sout, "invalid commandline option\n");
+ return EXIT_FAILURE;
+ }
+#endif
+
#ifndef G__SMALLOBJECT
G__more_pause((FILE*)NULL, 0);
fprintf(G__sout, usage, progname);
@@ -1080,6 +1103,9 @@
G__more(G__sout, "* -M [newdelmask] : operator new/delete mask for precompiled interface method\n");
G__more(G__sout, "* -n [linkname] : Specify precompiled interface method filename\n");
G__more(G__sout, "* -N [DLL_name] : Specify DLL interface method name\n");
+#ifdef G__PROHIBIT_INTERACTION
+ G__more(G__sout, " -o [1]: option : [1] Interaction with user prohibited\n");
+#endif
G__more(G__sout, " -O [0~4] : Loop compiler on(1~5) off(0). Default on(4)\n");
G__more(G__sout, " -p : use preprocessor prior to interpretation\n");
G__more(G__sout, " -q [security] : Set security level(default 0)\n");
@@ -1099,6 +1125,7 @@
G__more(G__sout, " -Y [0|1]: ignore std namespace (default=1:ignore)\n");
G__more(G__sout, " -Z [0|1]: automatic loading of standard header files with DLL\n");
G__more(G__sout, " --'command': Execute interactive command and terminate Cint\n");
+
G__more(G__sout, "suboptions\n");
G__more(G__sout, " +V : turn on class title comment mode for following source fies\n");
G__more(G__sout, " -V : turn off class title comment mode for following source fies\n");
@@ -1523,14 +1550,26 @@
alarm(G__TIMEOUT);
}
#endif
+
+#ifdef G__PROHIBIT_INTERACTION
+ if (prohibitinteraction == 0 && G__catchexception != 2) G__pause();
+#else
if (G__catchexception != 2) G__pause();
+#endif
+
#ifdef SIGALRM
if (G__RETURN_EXIT1 == G__return) {
alarm(0);
G__fprinterr(G__serr, "Time out cancelled\n");
}
#endif
+
+#ifdef G__PROHIBIT_INTERACTION
+ if (prohibitinteraction == 0 && G__catchexception != 2) G__pause();
+#else
if (G__catchexception != 2) G__pause();
+#endif
+
}
if (G__stepover) {
G__step = 0;
@@ -1560,7 +1599,24 @@
return EXIT_SUCCESS;
}
#endif
+
+#ifdef G__PROHIBIT_INTERACTION
+ /*****************************************
+ * If no main() and probibit interaction,
+ * Print out message and quit
+ *****************************************/
+ else if (prohibitinteraction == 1) {
+ if (!G__quiet) {
+ fprintf(G__sout, "No main() function found in given source file..\n");
+ }
+ G__return = G__RETURN_NON;
+ G__scratch_all();
+ return EXIT_FAILURE;
+ }
+#endif
+
else {
+
/*************************************
* If no main() ,
* Print out message and
regards
Jonathan Mitchell
cint.diff (4.32 KB)