subprocess - Debugging a Windows Service and trying to see what it sees -
we have automated system runs service processing satellite images. service maintains configuration file, in configuration file apply scripts(python) covnert input satellite imagery more usable format. scripts call required applications, conversion proces. scripts invoked service via system("command") (its written in c/c++). (the service uses same account user).
we trying add support satelitte imagery format, converter commerical .exe erdas imagine(importavhrr), (we several of our own steps after in script change projection).
the script works fine, until hits this:
argslist = ['importavhrr.exe', '-in', '%s' % infn, '-out', '%s' % tmpimg1, '-gui', 'false', '-correct', '-flyingheight', '833', '-rect', 'gcp', gcpfn] print "".join(argslist) p = subprocess.popen(argslist, shell=true, stderr=subprocess.pipe, stdout=subprocess.pipe) print str(p.communicate())
what ends happening is, importavhrr.exe sits there, , nothing(according taskmanager sits there using 0 cpu usage, , memory usage never changes). if waiting sort of user input. (trying os.system, os.spawnv both yield same results) guessing sort of gui element ether popping gui window of sorts. closing process task manager, returns control python.
note: -gui false/false/0 argument supposed prevent gui poping up. if data bad (i tested manually corrupting data, , invoking via script) error window popup showing results.
when run script manually (same file, same working directory), works fine.... script works when invoke manually using same system function (its part of inhouse library) service.
also making service invoke batch file importavhrr.exe , enviroment variables results in importavhrr.exe hanging.
service sidewise: - uses same user account 1 logged in - python script sets around 30-40 envrioment variables erdas - enviroment variables set(dumping enviroment variables when script first run, , comparing them when print messages) - passing enviroment variables subprocess.popen() yields same results - company refuses because don't support running programs command line (however works fine when user it, not service) - running service in debug mode works fine. - have rebooted machine.
i @ loss here, think (and fear) erdas executable making sort of error message window popup, have looked, , looked , can't find sort of way see service sees. have been trying figure out week yeah.
edit
i grabbed recommended process explorer, , looking @ stack thread have this:
<snip ntoskrnl calls> ntdll.dll!kifastsystemcallret ntdll.dll!rtlsetlastwin32errorandntstatusfromntstatus+0x301 kernel32.dll!getmodulehandlea+0xdf
after waiting few minutes, changes this:
<snip ntoskrnl calls> ntdll.dll!kifastsystemcallret user32.dll!scrollwindowex+0x121d user32.dll!softmodalmessagebox+0x6f8 user32.dll!messageboxtimeoutw+0x1d9 user32.dll!messageboxtimeoutw+0x5b user32.dll!messageboxtimeouta+0x9c user32.dll!messageboxexa+0x1b user32.dll!messageboxa+0x45 elib.dll!esmg_getlocaltapesdb+0x23b elib.dll!esmg_logmessagefunc+0x13a
well trying show window, presume. don't know behaviour see causing esmg_logmessagefunc crash. function part of dev tools, have 0 access to. furthermore have never seen erdas log anything.
trying use windows api calls assume access windowstation cause problems in security context of service.
you can use several of tools sysinternals diagnose kind of thing. specifically, consider using process explorer in place of task manager, , process monitor tracing activity of specific process.
edit: new procdump tool can used core dump of process powerful triggering. several of latest war stories on mark russinovich's blog take advantage of procdump discover happened.
for completeness, overview of "official" tools debugging service @ this kb article.
Comments
Post a Comment