Artifacts Associated With Ticket 813087ffffffffff
Ticket change [d6638170b7] (rid 123797) by dmacks on 2003-09-26 14:12:13:
- assignee initialized to: "andreas_kupries"
- cmimetype initialized to: "text/plain"
- comment initialized to:
tcltk-8.4.1 compiled from the unix/ directory on OS X 10.2.6. tcltk-8.3.4 that comes precompiled with my OS X is not affected. When tclsh is used in a pipeline, stdout is treated like a socket. This is bad because it defaults to CR/LF line endings, not the LF that is expected and appropriate for a Unix platform when parsing piped commands. Simple Unix file descriptor redirection does not have this problem. Here are three examples that look correct: % tclsh % fconfigure stdout -blocking 1 -buffering line -buffersize 4096 -encoding utf-8 -eofchar {} -translation crlf -mode 9600,n,8,1 -xchar {p r} [that {p r} is actually untypable characters) % echo "puts [fconfigure stdout]" | tclsh -blocking 1 -buffering line -buffersize 4096 -encoding utf-8 -eofchar {} -translation crlf -mode 9600,n,8,1 -xchar {p r} % echo "puts [fconfigure stdout]" | tclsh > foo ; cat -vte foo -blocking 1 -buffering line -buffersize 4096 -encoding utf-8 -eofchar {} -translation lf$ So simple output and redirected output and piped input are okay, but if output is piped: % echo "puts [fconfigure stdout]" | tclsh | cat -vte -blocking 1 -buffering line -buffersize 4096 -encoding utf-8 -eofchar {{} {}} -translation {auto crlf} -peername {0.0.0.0 0.0.0.0 0} -sockname {0.0.0.0 0.0.0.0 0}^M$ - foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dmacks"
- subsystem initialized to: "27. Channel Types"
- title initialized to: "tclsh treats Unix pipelines as sockets"
- type initialized to: "Bug"
Ticket change [356f679d16] (rid 106930) by cc_benny on 2003-09-26 21:58:47:
- icomment:
Logged In: YES user_id=143885 Preliminary points of analysis: - getsockopt() is called in tclUnixChan.c:Tcl_MakeFileChannel() to determine if a file handle is a socket. For anonymous pipes this returns -1/ENOTSOCK on Linux as expected, but on Mac OS X (10.3.6) it returns 0, so the pipe is handled as a socket. - This happens in 8.4.4. In 8.3.4 getsockopt() is not called at all according to ktrace/strace. I haven't investigated the 8.3 source yet, where the actual difference are here.
- login: "cc_benny"
- mimetype: "text/plain"
- username: "cc_benny"
- icomment:
Ticket change [d38dc3a95a] (rid 123309) by cc_benny on 2003-09-27 22:50:17:
- icomment:
Logged In: YES user_id=143885 More points: - Darwin/Mac OS X implements pipes as sockets internally. This is also on NetBSD. - The call to getsockopt() was added to tclUnixChan.c:Tcl_MakeFileChannel() in version 1.20 of the file by dkf (Donal K. Fellows) in response to bug #219137. See posting on a NetBSD list <http://groups.google.com/groups?selm=20010327154747.A13991%40vaasje.org> for alternative code to detect socket vs. other file types, based on getsockname(). That code works here on Mac OS X and could be used in Tcl_MakeFileChannel() instead of (or in addition to) getsockopt(SO_TYPE).
- login: "cc_benny"
- mimetype: "text/plain"
- username: "cc_benny"
- icomment:
Ticket change [a6f3573900] (rid 98698) by cc_benny on 2003-09-27 23:31:47:
- icomment:
Logged In: YES user_id=143885 See patch #813606.
- login: "cc_benny"
- mimetype: "text/plain"
- username: "cc_benny"
- icomment:
Ticket change [251d442528] (rid 131229) by jenglish on 2003-10-03 07:35:02:
- icomment:
Logged In: YES user_id=68433 From the patch: ! if (getsockname(fd, (struct sockaddr *)&sockaddr, &sockaddrLen) == 0 ! && sockaddrLen > 0 ! && sockaddr.ss_family != AF_UNSPEC ! && sockaddr.ss_family != AF_LOCAL) { ! return MakeTcpClientChannelMode((ClientData) fd, mode); A better test would be: if (sockaddrLen > 0 && sockaddr.ss_family == AF_INET) { ... } - login: "jenglish"
- mimetype: "text/plain"
- username: "jenglish"
- icomment:
Ticket change [7a41b5cb8d] (rid 90280) by cc_benny on 2003-10-03 20:37:28:
- icomment:
Logged In: YES user_id=143885 >if (sockaddrLen > 0 && sockaddr.ss_family == AF_INET) Don't forgot the call to getsockname(). AF_INET limits this function to IP. But the rest of the code is limited to IP anyway, so you are right.
- login: "cc_benny"
- mimetype: "text/plain"
- username: "cc_benny"
- icomment:
Ticket change [d58b6361af] (rid 123642) by andreas_kupries on 2003-10-24 01:03:19:
- closedate changed to: "2003-10-23T18:03:19"
- closer changed to: "andreas_kupries"
- icomment:
Logged In: YES user_id=75003 The referenced patch was accepted with small changes (see patch page) and committed to both head and core-8-4- branch. This fixes the bug.
- login: "andreas_kupries"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "andreas_kupries"