def cmd_capabilities(c, ce):
cmdnumargs(c, ce)
- return caller.hook_capabilities() + ['execute-debug']
+ return caller.hook_capabilities() + ['execute-debug',
+ 'print-execute-command']
def cmd_quit(c, ce):
cmdnumargs(c, ce)
if not downtmp: bomb("`close' when not open")
cleanup()
+def cmd_print_execute_command(c, ce):
+ cmdnumargs(c, ce)
+ if not downtmp: bomb("`print-execute-command' when not open")
+ if hasattr(caller,'hook_callerexeccmd'):
+ (cl,kvl) = caller.hook_callerexeccmd()
+ else:
+ cl = down
+ kvl = ['shstring']
+ return [','.join(map(urllib.quote, cl))] + kvl
+
def preexecfn():
caller.hook_forked_inchild()
"import os\n"
"def setfd(fd,fnamee,write,mode=0666):\n"
" fname = urllib.unquote(fnamee)\n"
- " if write: rw = os.O_WRONLY|os.O_CREAT\n"
+ " if write: rw = os.O_WRONLY|os.O_CREAT|os.O_TRUNC\n"
" else: rw = os.O_RDONLY\n"
" nfd = os.open(fname, rw, mode)\n"
" if fd >= 0: os.dup2(nfd,fd)\n"
c = map(urllib.unquote, ce)
if not c: bomb('empty commands are not permitted')
debug('executing '+string.join(ce))
- try: f = globals()['cmd_'+c[0]]
+ c_lookup = c[0].replace('-','_')
+ try: f = globals()['cmd_'+c_lookup]
except KeyError: bomb("unknown command `%s'" % ce[0])
try:
r = f(c, ce)
r = fc.e
print string.join(r)
+signal_list = [ signal.SIGHUP, signal.SIGTERM,
+ signal.SIGINT, signal.SIGPIPE ]
+
+def sethandlers(f):
+ for signum in signal_list: signal.signal(signum, f)
+
def cleanup():
global downtmp, cleaning
debug("cleanup...");
+ sethandlers(signal.SIG_DFL)
cleaning = True
if downtmp: caller.hook_cleanup()
cleaning = False
def prepare():
global downtmp, cleaning
downtmp = None
- signal_list = [ signal.SIGHUP, signal.SIGTERM,
- signal.SIGINT, signal.SIGPIPE ]
- def sethandlers(f):
- for signum in signal_list: signal.signal(signum, f)
def handler(sig, *any):
- sethandlers(signal.SIG_DFL)
cleanup()
os.kill(os.getpid(), sig)
sethandlers(handler)