Skip to content
Tcl Source Code Artifact [37726af194]
Login

Artifact [37726af194]

Artifact 37726af19487821b7ac214352794988a06f6c070:

Ticket change [37726af194] - New ticket [217794ffffffffff|217794ffff] <i>Sockets are incorrectly inherited in child processes on Win-</i>. by nobody on 2000-10-26 00:43:46.
D 2000-10-26T00:43:46
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s927\sBug\nVersion:\s8.1a2\nSubmitDate:\s'1998-12-04'\nLastModified:\s'1998-12-08'\nSeverity:\sMED\nStatus:\sClosed\nSubmitter:\swelch\nChangedBy:\sstanton\nRelatedBugIDs:\s892\nOS:\sWindows\sNT\nOSVersion:\s4.0\sService\sPack\s3\nMachine:\sX86\nFixedDate:\s'2000-10-25'\nClosedDate:\s'1998-12-08'\n\n\nName:\n\nKevin\sB.\sKenny\n\n\n\nExtensions:\n\nNone\srequired\sfor\sthis\stest.\n\n\n\nCustomShell:\n\nNone\srequired\sfor\sthis\stest.\n\n\n\nReproducibleScript:\n\n#\sWhen\sTcl\slaunches\sa\schild\sprocess\n\n#\swith\sthe\s'exec'\scommand\son\sWin-NT,\n\n#\sthe\shandles\sof\sany\sopen\ssockets\n\n#\sare\sinherited\sin\sthe\schild.\s\sIf\sthe\n\n#\sparent\sterminates\sand\sthe\schild\sdoes\n\n#\snot,\sthe\ssockets\sare\snever\sclosed.\n\n\n\n#\sThe\sfollowing\scode\scould\sbe\sadded\sto\s'socket.test'\sin\sthe\n\n#\sTcl\stest\ssuite;\sit\sexhibits\sthe\sthree\n\n#\scases\sof\sthis\sbehavior\s(server\n\n#\ssockets,\sclient\ssockets,\sand\saccepted\n\n#\ssockets).\n\n\n\n#########################################################################\n\n##\n\n#\sThe\sfollowing\stests\sfail\son\sWin-NT\sin\sall\sreleases\sof\sTcl\sup\sto#\n\n#\sand\sincluding\s8.1a2,\sbut\ssucceed\son\sUnix.\s\sThe\sproblem\sis\sthat#\n\n#\sNT\ssets\sthe\sHANDLE_FLAG_INHERIT\sbit\sfor\ssockets\sto\s1\sby\sdefault,#\n\n#\sso\sTcl\shas\sto\sturn\sit\soff.#\n\n##\n\n#########################################################################\n\n\n\ntest\ssocket-12.1\s{testing\sinheritance\sof\sserver\ssockets}\s{\n\n\s\s\s\sremoveFile\sscript1\n\n\s\s\s\sremoveFile\sscript2\n\n\n\n\s\s\s\s#\sScript1\sis\sjust\sa\s10\ssecond\sdelay.\s\sIf\sthe\sserver\ssocket\n\n\s\s\s\s#\sis\sinherited,\sit\swill\sbe\sheld\sopen\sfor\s10\sseconds\n\n\n\n\s\s\s\sset\sf\s[open\sscript1\sw]\n\n\s\s\s\sputs\s$f\s{\n\nafter\s10000\sexit\n\nvwait\sforever\n\n\s\s\s\s}\n\n\s\s\s\sclose\s$f\n\n\n\n\s\s\s\s#\sScript2\screates\sthe\sserver\ssocket,\slaunches\sscript1,\n\n\s\s\s\s#\swaits\sa\ssecond,\sand\sexits.\s\sThe\sserver\ssocket\swill\snow\n\n\s\s\s\s#\sbe\sclosed\sunless\sscript1\sinherited\sit.\n\n\n\n\s\s\s\sset\sf\s[open\sscript2\sw]\n\n\s\s\s\sputs\s$f\s[list\sset\stcltest\s$tcltest]\n\n\s\s\s\sputs\s$f\s{\n\nset\sf\s[socket\s-server\saccept\s2828]\n\nproc\saccept\s{\sfile\saddr\sport\s}\s{\n\n\s\s\s\sclose\s$file\n\n}\n\nexec\s$tcltest\sscript1\s&\n\nclose\s$f\n\nafter\s1000\sexit\n\nvwait\sforever\n\n\s\s\s\s}\n\n\s\s\s\sclose\s$f\n\n\n\n\s\s\s\s#\sLaunch\sscript2\sand\swait\s5\sseconds\n\n\n\n\s\s\s\sexec\s$tcltest\sscript2\s&\n\n\s\s\s\safter\s5000\s{\sset\sok_to_proceed\s1\s}\n\n\s\s\s\svwait\sok_to_proceed\n\n\n\n\s\s\s\s#\sIf\swe\scan\sstill\sconnect\sto\sthe\sserver,\sthe\ssocket\sgot\sinherited.\n\n\n\n\s\s\s\sif\s{[catch\s{socket\slocalhost\s2828}\smsg]}\s{\n\nset\sx\s{server\ssocket\swas\snot\sinherited}\n\n\s\s\s\s}\selse\s{\n\nclose\s$msg\n\nset\sx\s{server\ssocket\swas\sinherited}\n\n\s\s\s\s}\n\n\n\n\s\s\s\sremoveFile\sscript1\n\n\s\s\s\sremoveFile\sscript2\n\n\s\s\s\sset\sx\n\n}\s{server\ssocket\swas\snot\sinherited}\n\n\n\ntest\ssocket-12.2\s{testing\sinheritance\sof\sclient\ssockets}\s{\n\n\s\s\s\sremoveFile\sscript1\n\n\s\s\s\sremoveFile\sscript2\n\n\n\n\s\s\s\s#\sScript1\sis\sjust\sa\s10\ssecond\sdelay.\s\sIf\sthe\sserver\ssocket\n\n\s\s\s\s#\sis\sinherited,\sit\swill\sbe\sheld\sopen\sfor\s10\sseconds\n\n\n\n\s\s\s\sset\sf\s[open\sscript1\sw]\n\n\s\s\s\sputs\s$f\s{\n\nafter\s10000\sexit\n\nvwait\sforever\n\n\s\s\s\s}\n\n\s\s\s\sclose\s$f\n\n\n\n\s\s\s\s#\sScript2\sopens\sthe\sclient\ssocket\sand\swrites\sto\sit.\s\sIt\sthen\n\n\s\s\s\s#\slaunches\sscript1\sand\sexits.\s\sIf\sthe\schild\sprocess\sinherited\sthe\n\n\s\s\s\s#\sclient\ssocket,\sthe\ssocket\swill\sstill\sbe\sopen.\n\n\n\n\s\s\s\sset\sf\s[open\sscript2\sw]\n\n\s\s\s\sputs\s$f\s[list\sset\stcltest\s$tcltest]\n\n\s\s\s\sputs\s$f\s{\n\nset\sf\s[socket\slocalhost\s2829]\n\nexec\s$tcltest\sscript1\s&\n\nputs\s$f\stesting\n\nflush\s$f\n\nafter\s1000\sexit\n\nvwait\sforever\n\n\s\s\s\s}\n\n\s\s\s\sclose\s$f\n\n\n\n\s\s\s\s#\sCreate\sthe\sserver\ssocket\n\n\n\n\s\s\s\sset\sserver\s[socket\s-server\saccept\s2829]\n\n\s\s\s\sproc\saccept\s{\sfile\shost\sport\s}\s{\n\n\n\n#\sWhen\sthe\sclient\sconnects,\sestablish\sthe\sread\shandler\n\nglobal\sserver\n\nclose\s$server\n\nfileevent\s$file\sreadable\s[list\sgetdata\s$file]\n\nfconfigure\s$file\s-buffering\sline\s-blocking\s0\n\nreturn\n\n\s\s\s\s}\n\n\s\s\s\sproc\sgetdata\s{\sfile\s}\s{\n\n\n\n#\sRead\shandler\son\sthe\saccepted\ssocket.\n\nglobal\sx\n\nglobal\sfailed\n\nset\sstatus\s[catch\s{read\s$file}\sdata]\n\nif\s{$status\s!=\s0}\s{\n\n\s\s\s\sset\sx\s{read\sfailed,\serror\swas\s$data}\n\n\s\s\s\scatch\s{\sclose\s$file\s}\n\n}\selseif\s{[string\scompare\s{}\s$data]}\s{\n\n}\selseif\s{[fblocked\s$file]}\s{\n\n}\selseif\s{[eof\s$file]}\s{\n\n\s\s\s\sif\s{$failed}\s{\n\nset\sx\s{client\ssocket\swas\sinherited}\n\n\s\s\s\s}\selse\s{\n\nset\sx\s{client\ssocket\swas\snot\sinherited}\n\n\s\s\s\s}\n\n\s\s\s\scatch\s{\sclose\s$file\s}\n\n}\selse\s{\n\n\s\s\s\sset\sx\s{impossible\scase}\n\n\s\s\s\scatch\s{\sclose\s$file\s}\n\n}\n\nreturn\n\n\s\s\s\s}\n\n\n\n\s\s\s\s#\sIf\sthe\ssocket\sdoesn't\shit\send-of-file\sin\s5\sseconds,\sthe\n\n\s\s\s\s#\sscript1\sprocess\smust\shave\sinherited\sthe\sclient.\n\n\n\n\s\s\s\sset\sfailed\s0\n\n\s\s\s\safter\s5000\s[list\sset\sfailed\s1]\n\n\n\n\s\s\s\s#\sLaunch\sthe\sscript2\sprocess\n\n\n\n\s\s\s\sexec\s$tcltest\sscript2\s&\n\n\n\n\s\s\s\svwait\sx\n\n\s\s\s\sif\s{!$failed}\s{\n\nvwait\sfailed\n\n\s\s\s\s}\n\n\s\s\s\sremoveFile\sscript1\n\n\s\s\s\sremoveFile\sscript2\n\n\s\s\s\sset\sx\n\n}\s{client\ssocket\swas\snot\sinherited}\n\n\n\ntest\ssocket-12.3\s{testing\sinheritance\sof\saccepted\ssockets}\s{\n\n\s\s\s\sremoveFile\sscript1\n\n\s\s\s\sremoveFile\sscript2\n\n\n\n\s\s\s\sset\sf\s[open\sscript1\sw]\n\n\s\s\s\sputs\s$f\s{\n\nafter\s10000\sexit\n\nvwait\sforever\n\n\s\s\s\s}\n\n\s\s\s\sclose\s$f\n\n\n\n\s\s\s\sset\sf\s[open\sscript2\sw]\n\n\s\s\s\sputs\s$f\s[list\sset\stcltest\s$tcltest]\n\n\s\s\s\sputs\s$f\s{\n\nset\sserver\s[socket\s-server\saccept\s2930]\n\nproc\saccept\s{\sfile\shost\sport\s}\s{\n\n\s\s\s\sglobal\stcltest\n\n\s\s\s\sputs\s$file\s{test\sdata\son\ssocket}\n\n\s\s\s\sexec\s$tcltest\sscript1\s&\n\n\s\s\s\safter\s1000\sexit\n\n}\n\nvwait\sforever\n\n\s\s\s\s}\n\n\s\s\s\sclose\s$f\n\n\n\n\s\s\s\s#\sLaunch\sthe\sscript2\sprocess\sand\sconnect\sto\sit.\s\sSee\show\slong\n\n\s\s\s\s#\sthe\ssocket\sstays\sopen\n\n\n\n\s\s\s\sexec\s$tcltest\sscript2\s&\n\n\n\n\s\s\s\safter\s1000\sset\sok_to_proceed\s1\n\n\s\s\s\svwait\sok_to_proceed\n\n\n\n\s\s\s\sset\sf\s[socket\slocalhost\s2930]\n\n\s\s\s\sfconfigure\s$f\s-buffering\sfull\s-blocking\s0\n\n\s\s\s\sfileevent\s$f\sreadable\s[list\sgetdata\s$f]\n\n\n\n\s\s\s\s#\sIf\sthe\ssocket\sis\sstill\sopen\safter\s5\sseconds,\sthe\sscript1\sprocess\n\n\s\s\s\s#\smust\shave\sinherited\sthe\saccepted\ssocket.\n\n\n\n\s\s\s\sset\sfailed\s0\n\n\s\s\s\safter\s5000\sset\sfailed\s1\n\n\n\n\s\s\s\sproc\sgetdata\s{\sfile\s}\s{\n\n\n\n#\sRead\shandler\son\sthe\sclient\ssocket.\n\nglobal\sx\n\nglobal\sfailed\n\nset\sstatus\s[catch\s{read\s$file}\sdata]\n\nif\s{$status\s!=\s0}\s{\n\n\s\s\s\sset\sx\s{read\sfailed,\serror\swas\s$data}\n\n\s\s\s\scatch\s{\sclose\s$file\s}\n\n}\selseif\s{[string\scompare\s{}\s$data]}\s{\n\n}\selseif\s{[fblocked\s$file]}\s{\n\n}\selseif\s{[eof\s$file]}\s{\n\n\s\s\s\sif\s{$failed}\s{\n\nset\sx\s{accepted\ssocket\swas\sinherited}\n\n\s\s\s\s}\selse\s{\n\nset\sx\s{accepted\ssocket\swas\snot\sinherited}\n\n\s\s\s\s}\n\n\s\s\s\scatch\s{\sclose\s$file\s}\n\n}\selse\s{\n\n\s\s\s\sset\sx\s{impossible\scase}\n\n\s\s\s\scatch\s{\sclose\s$file\s}\n\n}\n\nreturn\n\n\s\s\s\s}\n\n\s\s\s\s\n\n\s\s\s\svwait\sx\n\n\n\n\s\s\s\sremoveFile\sscript1\n\n\s\s\s\sremoveFile\sscript2\n\n\s\s\s\sset\sx\n\n}\s{accepted\ssocket\swas\snot\sinherited}\n\n\n\n\n\n\n\n\n\nObservedBehavior:\n\nThe\sthree\stests\sabove\sall\sfail,\n\nreporting\sthat\sthe\ssocket\swas\sinherited\n\nin\sthe\schild\sprocess.\s\s(All\sthree\spass\n\non\sSolaris.)\n\n\n\n\n\n\n\nDesiredBehavior:\n\nThe\sthree\stests\sshould\sall\spass.\n\n\n\n\n\n\n\nPatch:\n\n***\stclWinSock.c.origFri\sFeb\s20\s18:19:56\s1998\n\n---\stclWinSock.cThu\sDec\s\s3\s17:01:54\s1998\n\n***************\n\n***\s985,990\s****\n\n---\s985,997\s----\n\n\s\s\s\s\s\s}\n\n\s\s\n\n\s\s\s\s\s\s/*\n\n+\s\s\s\s\s\s*\sWin-NT\shas\sa\smisfeature\sthat\ssockets\sare\sinherited\sin\schild\n\n+\s\s\s\s\s\s*\sprocesses\sby\sdefault.\s\sTurn\soff\sthe\sinherit\sbit.\n\n+\s\s\s\s\s\s*/\n\n+\s\n\n+\s\s\s\s\sSetHandleInformation(\s(HANDLE)\ssock,\sHANDLE_FLAG_INHERIT,\s0\s);\n\n+\s\n\n+\s\s\s\s\s/*\n\n\s\s\s\s\s\s\s*\sSet\skernel\sspace\sbuffering\n\n\s\s\s\s\s\s\s*/\n\n\s\s\n\n***************\n\n***\s1486,1491\s****\n\n---\s1493,1505\s----\n\n\s\s\s\s\s\sif\s(newSocket\s==\sINVALID_SOCKET)\s{\n\n\s\s\s\s\s\s\s\s\s\sreturn;\n\n\s\s\s\s\s\s}\n\n+\s\n\n+\s\s\s\s\s/*\n\n+\s\s\s\s\s\s*\sWin-NT\shas\sa\smisfeature\sthat\ssockets\sare\sinherited\sin\schild\n\n+\s\s\s\s\s\s*\sprocesses\sby\sdefault.\s\sTurn\soff\sthe\sinherit\sbit.\n\n+\s\s\s\s\s\s*/\n\n+\s\n\n+\s\s\s\s\sSetHandleInformation(\s(HANDLE)\snewSocket,\sHANDLE_FLAG_INHERIT,\s0\s);\n\n\s\s\n\n\s\s\s\s\s\s/*\n\n\s\s\s\s\s\s\s*\sAdd\sthis\ssocket\sto\sthe\sglobal\slist\sof\ssockets.\n\n\n\n\n\n\n\n\n\nPatchFiles:\n\ntclWnSock.c\n\n\n\n\n\n\n\n\n\nFOR\sTHE\sATTENTION\sOF\sSCOTT\sSTANTON:\nWe\shave\sdiscussed\sthis\sproblem\sin\na\stelephone\sconversation\son\n2\sDecember\s1998\n
J foundin obsolete:\s8.1a2
J priority 5\sMedium
J resolution None
J status Open
J submitter nobody
J subsystem 69.\sOther
J title Sockets\sare\sincorrectly\sinherited\sin\schild\sprocesses\son\sWin-
J type Bug
K 217794ffffffffffffffffffffffffffffffffff
U nobody
Z 7acd9836997d7df02272fba2f66d6d94