Tcl Source Code

View Ticket
Login
Ticket UUID: 437489
Title: Tk console breaks [exec]
Type: Bug Version: obsolete: 8.3.3
Submitter: dgp Created on: 2001-06-29 22:51:06
Subsystem: 27. Channel Types Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2001-12-11 09:43:43
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2001-12-11 02:43:43
Description:
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.
User Comments: andreas_kupries added on 2001-12-11 09:43:43:
Logged In: YES 
user_id=75003

Patch committed to head.

andreas_kupries added on 2001-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 added on 2001-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?

dgp added on 2001-06-30 05:52:45:

File Added - 7947: pipe.patch

Logged In: YES 
user_id=80530

Here's the patch...

dgp added on 2001-06-30 05:51:07:

File Added - 7946: mywish.c

Attachments: