Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-12-11
09:43 • Closed ticket [437489ffff]: Tk console breaks exec plus 7 other changes artifact: 7103bab1bf user: andreas_kupries
2001-12-08
00:06 • Ticket [437489ffff]: 1 change artifact: 9c1e953554 user: dgp
2001-08-23
05:57 • Ticket [437489ffff]: 4 changes artifact: f820b3208d user: andreas_kupries
2001-07-06
02:27 • Ticket [437489ffff]: 4 changes artifact: 1bf291e645 user: dgp
2001-06-30
05:52 • Add attachment pipe.patch to ticket [437489ffff] artifact: 57ec2726c5 user: dgp
05:52 • Ticket [437489ffff] Tk console breaks exec status still Open with 4 other ... artifact: c761be4089 user: dgp
05:51 • Ticket [437489ffff]: 4 changes artifact: 793a0c587a user: dgp
05:51 • Add attachment mywish.c to ticket [437489ffff] artifact: add96b3802 user: dgp
2001-06-29
22:51 • New ticket [437489ffff] Tk console breaks exec. artifact: af488bdaeb user: dgp

Tk console breaks [exec]

Closed / Fixed437489ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-06-29 22:51:06
The attached file, mywish.c, creates a customized
"wish" program on Unix that makes use of the Tk
console developed for Windows.  The routines that
make this possible, Tk_InitConsoleChannels() and
Tk_CreateConsoleWindow() are public.

Create a program from the attached file with gcc
like so:

gcc -o mywish mywish.cc -ltk8.3 -ltcl8.3

Then start ./mywish and up pops the console.
So far so good.

Enter in the console:

% exec xeyes &;# or whatever is available
forked process couldn't set up input/output: bad file
number
% set errorCode
POSIX EBADF {bad file number}

I tracked down the problem in unix/tclUnixPipe.c
and will attach a one-liner patch that fixes it.
dgpplain2001-06-30 05:51:07
File Added - 7946: mywish.c
dgpplain2001-06-30 05:52:45
File Added - 7947: pipe.patch

Logged In: YES 
user_id=80530

Here's the patch...
dgpplain2001-07-06 02:27:18
Logged In: YES 
user_id=80530

Note that after this fix, the child process can
start up, but it will have no standard channels.
(File descriptors 0, 1, 2 will be closed).

Unless the child process handles that possibility,
there can still be trouble.  Note especially that
if the child process includes a Tcl interp, the
first 3 channels created will "become" stdin,
stdout and stderr.  Unless that is controlled
carefully, it will probably lead to unpredictable
behavior.

Can anyone explain why Tcl_CreateChannel does that?
andreas_kupriesplain2001-08-23 05:57:14
Logged In: YES 
user_id=75003

It allows you to close stdout, open a file (or socket) and 
thus have that file/socket as the new stdout of the 
application.
dgp Ticket [437489ffff]: 1 change [History diff]2001-12-08 00:06:28
andreas_kupriesplain2001-12-11 09:43:43
Logged In: YES 
user_id=75003

Patch committed to head.
Log in (anonymous is fine) to add a comment.

Attachments: