Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-10-25
22:51 • Closed ticket [471374ffff]: Child process doesn't detach with & plus... artifact: 5e6b1a455d user: dkf
20:45 • Ticket [471374ffff]: 1 change artifact: a2716399f8 user: andreas_kupries
10:54 • Ticket [471374ffff]: 4 changes artifact: 402eb692f3 user: andreas_kupries
2001-10-24
23:27 • Ticket [471374ffff]: 4 changes artifact: d15638a33c user: dgp
22:54 • Ticket [471374ffff]: 4 changes artifact: 9b3d70ca81 user: chris_nelson
05:27 • Ticket [471374ffff]: 4 changes artifact: c1cd46dad4 user: dgp
03:52 • Ticket [471374ffff]: 4 changes artifact: f432ed18dc user: dgp
03:46 • Ticket [471374ffff]: 4 changes artifact: 81ff9bd9fb user: chris_nelson
03:39 • Ticket [471374ffff]: 4 changes artifact: 42f3d681cd user: dgp
2001-10-16
19:22 • Ticket [471374ffff]: 2 changes artifact: 6f449cfefa user: dkf
03:45 • Ticket [471374ffff]: 4 changes artifact: 6ace41c43e user: chris_nelson
03:33 • Ticket [471374ffff]: 4 changes artifact: efa3f26681 user: dgp
00:37 • Ticket [471374ffff]: 4 changes artifact: 05d229a7e3 user: chris_nelson
2001-10-15
17:27 • New ticket [471374ffff]. artifact: e35b345094 user: chris_nelson

Child process doesn't detach with &

Closed / Fixed471374ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-10-15 17:27:40
On at leats Soliaris (`uname -a` gives "SunOS urchin 5.8 Generic_108528-05 
sun4u sparc SUNW,UltraSPARC-IIi-Engine"), scripts which start children with 
& to background and detach the child process seem to hand on some channel 
i/o when backgrounded.

A sample parent script:

   set wish [file join [file dirname [info nameofexecutable]] wish]
   set script execTestChild.tcl
   set options [list >& /dev/null &]
   eval exec [list $wish $script] $options
   after 30000

A stupid child script:

   tk_messageBox -message "I'm the child"
   exit

Now, run the parent with:

   tclsh execTest.tcl &

In 8.4a3, when the after has expired and the parent wants to exit, it hangs.  `jobs` reports:

   [1]  + Suspended (tty output)  ...

Furthermore, the child freezes.  If a window is put over the message box and removed, the 
message box does not redraw.  Foregrounding the parent and letting it terminate lets the child 
redraw.  (Note that there is no actual output from the parent when it it foregrounded.)

This behavior is not seen in 8.2.  That is, in 8.2, the parent exits cleanly without the tty output 
suspension and the child appears to be properly detached.
chris_nelsonplain2001-10-16 00:37:04
Logged In: YES 
user_id=107514

This also fails on HP-UX (HP-UX xxxx B.10.20 A 9000/715 2002497068 two-user license), AIX (AIX xxxx 3 4 
003C87964C00), and Linux (Linux xxxx.pinebush.com 2.2.17-8enterprise #1 SMP Fri Nov 17 16:02:20 EST 
2000 i686 unknown).
dgpplain2001-10-16 03:33:57
Logged In: YES 
user_id=80530

Unless I'm mistaken, this is a bug in wish (thus Tk)
not in Tcl/tclsh.

See

http://sf.net/tracker/index.php?func=detail&aid=465761&group_id=12997&atid=112997
chris_nelsonplain2001-10-16 03:45:52
Logged In: YES 
user_id=107514

I think you are mistaken (or this is a different problem).  I've reduced this to:

   exec emacs foo.test >& /dev/null &
   after 15000

which I invoke with:

   tclsh execTest.tcl

After 15 seconds, tclsh goes suspended and the emacs window won't update.
When I fg the tclsh, it terminates cleanly (with no output) and the emacs 
window is responsive again.
dkf Ticket [471374ffff]: 2 changes [History diff]2001-10-16 19:22:19
dgpplain2001-10-24 03:39:45
Logged In: YES 
user_id=80530

I cannot reproduce this using Tcl 8.4a3 (or any other Tcl)
on

SunOS ... 5.8 Generic_108528-10 sun4u sparc SUNW,Ultra-80
chris_nelsonplain2001-10-24 03:46:16
Logged In: YES 
user_id=107514

Thanks, Don.  I'm an idiot.  You have to invoke the script with:

   tclsh execTest.tcl &

(That is, it must be backgrounded.)
dgpplain2001-10-24 03:52:07
Logged In: YES 
user_id=80530

Ah!  Now I can confirm the problem in the current HEAD.

No bug in Tcl 8.3.4 though.

Now tracking down the various Tcl 8.4aX releases...
dgpplain2001-10-24 05:27:51
Logged In: YES 
user_id=80530

Confirmed this bug was introduced somewhere between
the Tcl 8.4a2 and Tcl 8.4a3 releases.

Suspects (see ChangeLog):

Patch 402924
Bug 219137
Patch 442636
chris_nelsonplain2001-10-24 22:54:35
Logged In: YES 
user_id=107514

Building Tcl 8.4a3 with 1.19 of tclUnixChan.c seems to fix the problem.  That 
fixes it for _us_ for the time being but I'll try to spend _some_ time figuring 
out what about tclUnixChan.c v1.20 is broken.  BTW, I can't find a bug 219137
as mentioned below and in the Tcl ChangeLog.  tclUnixChan.c v1.20 is supposed 
to address that bug but I can't figure out what it's about.
dgpplain2001-10-24 23:27:23
Logged In: YES 
user_id=80530

It refers to Tcl Patch 219137.

http://sf.net/tracker/index.php?func=detail&aid=219137&group_id=10894&atid=310894
andreas_kupriesplain2001-10-25 10:54:38
Logged In: YES 
user_id=75003

I remember that I made a stab at the bug which introduced
this problem and gave up when Donal came with his solution
and it worked.

I believe it is the change in Tcl_MakeFileChannel which
causes this. The child calls TclpGetDefaultStdChannel () for
its stdin, this in turn goes through Tcl_MakeFileChannel ().
Since v1.20 this now detects and configures the channel as
tty. The essential difference is that now the os handle is
queried for the tty configuration.
andreas_kupries Ticket [471374ffff]: 1 change [History diff]2001-10-25 20:45:46
dkfplain2001-10-25 22:51:34
Logged In: YES 
user_id=79902

Hmm. On Solaris8, the parent blocks in an ioctl() in
TtyCloseProc() when it is trying to restore the channel to
the state it was in initially.  The child is in select()
(but I suspect the problem there is due to signal
propagation, but that's not 100% a bad thing, and I don't
intend to address it. I'm also not a signal handling guru!)

Adding a state flag so the reset only happens when we've
changed something seems to fix the problem.
Log in (anonymous is fine) to add a comment.