.
D 2004-05-04T13:37:46
J assignee andreas_kupries
J cmimetype text/plain
J comment \nIf\sI\screate\sa\scommand\schannel\sand\sconfigure\sit\sas\snon-\nblocking,what\sshould\nhappen\sif\sI\sclose\sthe\schannel\swhile\sthe\schild\sprocess\s\ncontinues\sto\srun?\nIt\sseems\sreasonable\sthat\sa\snon-blocking\schannel\sshould\s\nnot\sblock\son\sclose,\nand\sthe\smanual\sstates\sthat\sflushing\sfor\sa\snon-blocking\s\nchannel\soccurs\sin\nthe\sbackground.\sI\sadmit\sit\sdoes\snot\sexplicitly\sstate\sthat\s\nclose\scannot\sblock\sin\nsuch\sa\scase.\s\n\nThe\seffect\sI\sam\sseeing\susing\sis\sthat\son\sSolaris\s2.8\sclose\s\ndoes\sreturn\nimmediately\sbut\son\sWindows\sXP\sit\sblocks.\n\nThe\straceback\sat\swhich\sit\sblocks\sis\sthe\sfollowing:\n\n\s\s\sWaitForSingleObject\n\s\s\sTcl_WaitPid(Tcl_Pid_\s*\s0x00000790,\sint\s*\s0x0026f1c4,\s\nint\s0)\sline\s2537\n\s\s\sTclCleanupChildren(Tcl_Interp\s*\s0x00979788,\sint\s1,\s\nTcl_Pid_\s*\s*\s0x00996240,\sTcl_Channel_\s*\s0x00995770)\s\nline\s294\s+\s21\sbytes\n\s\s\sPipeClose2Proc(void\s*\s0x00996338,\sTcl_Interp\s*\s\n0x00979788,\sint\s0)\sline\s2065\s+\s27\sbytes\n\s\s\sCloseChannel(Tcl_Interp\s*\s0x00979788,\sChannel\s*\s\n0x00994c28,\sint\s0)\sline\s2277\s+\s22\sbytes\n\s\s\sFlushChannel(Tcl_Interp\s*\s0x00979788,\sChannel\s*\s\n0x00994c28,\sint\s0)\sline\s2182\s+\s17\sbytes\n\s\s\sTcl_Close(Tcl_Interp\s*\s0x00979788,\sTcl_Channel_\s*\s\n0x00994c28)\sline\s2582\s+\s15\sbytes\n\s\s\sTcl_UnregisterChannel(Tcl_Interp\s*\s0x00979788,\s\nTcl_Channel_\s*\s0x00994c28)\sline\s847\s+\s13\sbytes\n\s\s\sTcl_CloseObjCmd(void\s*\s0x00000000,\sTcl_Interp\s*\s\n0x00979788,\sint\s2,\sTcl_Obj\s*\sconst\s*\s0x0097a964)\sline\s\n544\s+\s13\sbytes\n\s\s\sTclEvalObjvInternal(Tcl_Interp\s*\s0x00979788,\sint\s2,\s\nTcl_Obj\s*\sconst\s*\s0x0097a964,\sconst\schar\s*\s\n0x00000000,\sint\s0,\sint\s0)\sline\s3084\s+\s25\sbytes\n\s\s\sTclExecuteByteCode(Tcl_Interp\s*\s0x00979788,\s\nByteCode\s*\s0x00995900)\sline\s1401\s+\s33\sbytes\n\s\s\sTclCompEvalObj(Tcl_Interp\s*\s0x00979788,\sTcl_Obj\s*\s\n0x00993570)\sline\s980\s+\s13\sbytes\n\s\s\sTcl_EvalObjEx(Tcl_Interp\s*\s0x00979788,\sTcl_Obj\s*\s\n0x00993570,\sint\s0)\sline\s4004\s+\s13\sbytes\n\s\s\sTcl_CatchObjCmd(void\s*\s0x00000000,\sTcl_Interp\s*\s\n0x00979788,\sint\s2,\sTcl_Obj\s*\sconst\s*\s0x0026fb58)\sline\s\n254\s+\s18\sbytes\n\s\s\sTclEvalObjvInternal(Tcl_Interp\s*\s0x00979788,\sint\s2,\s\nTcl_Obj\s*\sconst\s*\s0x0026fb58,\sconst\schar\s*\s\n0x00992471,\sint\s17,\sint\s0)\sline\s3084\s+\s25\sbytes\n\s\s\sTcl_EvalEx(Tcl_Interp\s*\s0x00979788,\sconst\schar\s*\s\n0x00992278,\sint\s522,\sint\s0)\sline\s3674\s+\s36\sbytes\n\s\s\sTcl_FSEvalFile(Tcl_Interp\s*\s0x00979788,\sTcl_Obj\s*\s\n0x00993ac8)\sline\s1603\s+\s19\sbytes\n\s\s\sTcl_Main(int\s1,\schar\s*\s*\s0x00976cac,\sint\s(Tcl_Interp\s\n*)*\s0x00401005\s_Tcl_AppInit)\sline\s292\s+\s18\sbytes\n\s\s\smain()\sline\s117\s+\s19\sbytes\n\s\s\sTCLSH84!\smainCRTStartup\s+\s227\sbytes\n\s\s\sKERNEL32!\s77e7eb69()\n\nNote\sthat,\seven\sthough\sthe\schannel\sis\snon-blocking,\s\nTclCleanupChildren()\ncalls\sTcl_WaitPid()\spassing\swith\sargument\soptions\sset\sto\s\n0,\si.e.\sthe\sWNOHANG\nbit\sis\sclear\sso\sTcl_WaitPid()\sdoes\sblock.\n\nI\soriginally\sencountered\sthis\sproblem\swith\san\srsh\s\ncommand\sthat\sblocks.\nHowever,\sI\scan\sget\sthe\ssame\seffect\sjust\sstarting\sa\s\ntclsh.\sMy\stest\sscript\nis\sas\sfollows:\n\n#\sStart\stest\sscript\n\nproc\sgetData\s{f}\s{\n\s\s\sif\s{[eof\s$f]}\s{\n\s\s\s\s\s\sset\s::runFinished\s1\n\s\s\s\s\s\safter\scancel\s$::runTimeoutId\n\s\s\s\s\s\sreturn\n\s\s\s}\n\n\s\s\sputs\s"getData\s[gets\s$f]"\n}\n\n\nproc\srunFailed\s{args}\s{\n\s\s\sset\s::runFinished\s1\n\s\s\sputs\s"runFailed\s$args"\n}\n\nset\stimeout\s5\nset\s::runData\s""\n\n#\sOriginally\sdoing\sthis\swith\san\s'rsh'\scommand\sthat\sfailed\s\nto\sterminate.\n#\sset\scmd\s"rsh\sdv45ixl\sls"\n\n#\sFor\ssimplicity,\scan\sjust\sstart\san\sinteractive\stclsh,\sthis\s\nwaits\n#\sfor\sa\scommand\son\sstdin\sso\sit\salso\shangs.\nset\scmd\s"tclsh84"\n\nputs\s"Starting\scmd\s$cmd"\nset\sf\s[open\s"|$cmd"]\nfconfigure\s$f\s-blocking\s0\nfileevent\s$f\sreadable\s"getData\s$f"\nset\s::runTimeoutId\s[after\s[expr\s$timeout\s*\s1000]\s\nrunFailed\s$cmd]\nvwait\srunFinished\nunset\s::runFinished\n\nputs\s"closing\scommand\schannel"\ncatch\s{close\s$f}\nputs\s"Command\schannel\sclosed"\n\n#\sEnd\stest\sscript\n\nI\soriginally\sencountered\sthis\susing\smy\sown\sbuild\sof\sTcl\s\n8.4.3\sand\sthe\straceback\srelates\sto\sthis\sversion.\nI\shave\salso\sreproduced\sthe\sproblem\susing\sActiveTcl\s\n8.4.6.\n
J foundin obsolete:\s8.4.6
J priority 5\sMedium
J resolution None
J status Open
J submitter stevebold
J subsystem 25.\sChannel\sSystem
J title Close\son\snon-blocking\schannel\scan\sblock
J type Bug
K 947693ffffffffffffffffffffffffffffffffff
U stevebold
Z edcf61050056ff7929dc8fac504d9f68