This patch fixes a problem in bgexec. When the output
of bgexec
is redirected, multiple TimerProc tokens are created.
However,
the variable storing the Tcl timer handler token is
overwrittten.
When the process exits, only one of the timer handlers
is removed,
namely, the one still with a reference. During the
exit procedure,
the background data structure is freed. An access
violation occurs
when one of the other timer handlers is serviced by the
Tcl core
and the callback function TimerProc references the deleted
background data structure. This patch creates an
array which
stores each of the timer handler tokens in an array. During
exit each timer handler is deleted in turn. The array
is dynamic
and managed to allow any number of timers. This may not
be the best solution to the problem as I didn't know
the authors
original intent. A simplier solution of just using the
same handler
might work as well.
Patch for bgexec TimerProc crash