.
D 2009-04-10T15:17:34
J assignee mdejong
J cmimetype text/plain
J comment I\soriginally\swrote\sthis\sback\sin\sJuly\sof\s2008,\sbut\sI\sdid\snot\ssubmit\sit\sbecause\smy\sworkaround\sis\sworking\sfine\sfor\sme.\s\sHowever,\sthere\sis\sa\scurrent\sdiscussion\son\sthe\snewsgroup\swhich\sappears\sto\sbe\srelated.\n---\n\nI've\sbeen\sstruggling\swith\sthis\sone\sliterally\sfor\syears,\sand\sI\sfinally\sfigured\sout\swhat's\shappening.\s\sThe\sapparent\ssolutions\sseem\sto\shave\swarning\sflags\sall\sover\sthem,\sthough.\n\nI\shave\sa\sserver\sprocess\srunning\son\sa\sWindows\sbox\sthat\sspawns\stclsh\sprocesses\swhich\sdo\ssome\swork\sand\sthen\sexit.\s\sMost\sof\sthe\stime,\sall\sis\swell.\s\sHowever,\ssometimes\sthe\sserver\sgets\sback\sthe\swrong\sexit\scode\sfrom\sthe\ssubprocess.\s\sOther\stimes,\sthe\ssubprocess\snever\sends\sat\sall,\sdespite\sthe\sfact\sthat\sthe\sscript\sended.\s\sWhen\sI've\ssnooped\sthose\sorphan\sprocesses\swith\sthe\sProcess\sExplorer,\sI've\sseen\sa\sthread\ssitting\sthere\sjust\sspinning\sin\swhat\slooks\slike\ssome\sNT\slibrary\scall.\s\sOut\sof\stens\sof\sthousands\sof\stclsh\sprocesses,\syou\smight\snot\ssee\sit\shappen,\sand\sI'd\snever\sbeen\sable\sto\sget\sit\sto\shappen\son\spurpose\sso\sI\scould\strap\sit\sand\ssee\swhat\swas\sgoing\son.\s\sNowadays,\smy\sTcl\sscripts\sare\susing\sTclBlend\sto\srun\ssome\sJava\scode,\sand\sabout\sa\syear\sago\sI\sdiscovered\sthat\sif\sused\sthe\sJava\sexit\s(e.g.,\sfrom\sTcl,\sjava::call\sSystem\sexit\s$code),\sthen\sthe\sproblems\sdid\snot\shappen\sanymore.\s\sI\shad\sassumed\sthat\ssomething\sin\sthe\sTcl\scleanup\son\sexit\swas\sthe\scause\sof\smy\sproblem,\sand\sthe\sJava\scall\swas\sskipping\sit.\s\sI\snever\snoticed\sany\sill\seffects\sfrom\sdoing\sthis,\sso\sI\sleft\sit\sthat\sway.\s\s(Note\sthat\sthe\sexit\sproblems\spredate\sthe\suse\sof\sTclBlend\sin\sthe\sapplication,\sso\sI\sam\spretty\ssure\sthat\slibrary\sat\sleast\sis\snot\sthe\scause\sof\sthe\sproblems!)\n\nThis\sweek,\sthough,\sI\swas\susing\sa\sTCL_MEM_DEBUG\sbuild\sto\stry\sto\strack\sdown\sthe\ssource\sof\sa\s"TclStackFree:\sincorrect\sfreePtr.\sCall\sout\sof\ssequence?"\smessage.\s\sIn\sdoing\ssome\sbasic\ssanity\stests\swith\sthat\sbuild\sbefore\sI\stried\sto\suse\sit\swith\sthe\sapplication,\sI\sdiscovered\sthat\sno\smatter\swhat\sI\sdid,\sthat\sbuild\salways\sreturned\san\sexit\scode\sof\s0\sto\sthe\sparent\sprocess.\s\sHowever,\sif\sI\sconfigured\swith\sthe\s--disable-shared\soption,\sI\salways\sgot\sthe\sright\sexit\sstatus.\s\sI\scompared\sboth\sof\sthose\sbuilds\sin\sthe\sdebugger,\sand\sI\sfound\sout\sthat\sTcl\swas\scompleting\sits\scleanup\sfully\sin\sboth\scases\sand\spassing\sthe\scorrect\serror\scode\sto\sthe\sreal\s"exit"\scall,\sbut\sin\sone\scase\sit\swas\sgetting\slost\sbefore\sthe\sprocess\sreally\sended.\n\nThis\sled\sme\sto\sgo\slearn\smore\sthan\sI\swanted\sto\sknow\sabout\sWindows\sand\show\sit\sattempts\sto\sterminate\sprocesses,\sbut\sthe\slong\sand\sthe\sshort\sof\sit\sis\sthat\sunless\syou\scall\sTerminateProcess,\sWindows\stries\sto\sbe\snice\sand\slet\sthings\sclean\sup\sproperly,\sand\sthat\scan\shave\sthe\seffect\sof\sthe\sexit\scode\sbeing\schanged\sor\sthe\sprocess\snot\seven\sending.\s\sThey\sstrongly\sdiscourage\sthe\suse\sof\sTerminateProcess\sbecause\sit\sdoesn't\sallow\sloaded\sDLLs\sa\schance\sto\sexecute\stheir\scleanup\scode,\sbut\sthey\salso\ssay\sthat\seven\sif\syou\sexit\snicely\sthat\sDLL\scleanup\scode\sgets\sno\sguarantees\sthat\sany\sof\sits\sdata\sstructures\sare\sin\sa\sconsistent\sstate.\s\s\n\nI\sfound\san\sold\sbug\sreport\sat\sSun's\sJava\ssite\sstating\sthat\sthey\suse\sTerminateProcess\son\sWindows\sbecause\sit's\sthe\sonly\sway\sto\sguarantee\sthat\sthe\sprocess\sends,\sso\sthat\sexplains\swhy\scalling\sthe\sJava\sexit\scommand\sseemed\sto\shelp\sme.\s\sSo\sthat's\sthe\squestion.\s\sIs\sit\ssafe\sto\sreplace\sexit(code)\swith\sTerminateProcess(GetCurrentProcess(),\scode)\sin\sthe\sWindows\sversion\sof\sTcl?\s\sI've\sdone\sthis\sin\smy\scopy,\sand\sit's\sworking\sfine\swith\sall\smy\stests.\s\s\n
J foundin obsolete:\s8.5.6
J is_private 0
J priority 5\sMedium
J resolution None
J status Open
J submitter ajpasadyn
J subsystem 52.\sPortability\sSupport
J title Tcl\sexit\scan\smisbehave\son\sWindows
J type Bug
K 2750491fffffffffffffffffffffffffffffffff
U ajpasadyn
Z 69674a914df2a6b33a9727f7a13e715d