#1 RFE: make exit functionality similar2tcl

closed
None
5
2002-03-25
2001-07-06
Hemang Lavana
No

Hello,

The expect interpreter calls Tcl_Exit function at the end to terminate a
script. Due to this, we cannot do additional cleanup (ie. collect
profiling data and save it in a file) on exit.

Would it be reasonable to ask that the exit functionality of expect be
changed to follow that of the tclsh interpreter?

Here's the relevant code from tclMain.c file that should replace the
Tcl_Exit function call in exp_main_exp.c file:

/* need to declare buffer[1000] variable */

/*
* Rather than calling exit, invoke the "exit" command so that
* users can replace "exit" with some other command to do additional
* cleanup on exit. The Tcl_Eval call should never return.
*/

sprintf(buffer, "exit %d", exitCode);
Tcl_Eval(interp, buffer);

The Tcl_Exit function is invoked in the following files.

godel> fgrep -l Tcl_Exit *.c
exp_command.c
exp_main_exp.c
exp_main_sub.c
exp_main_tk.c
exp_tty.c

Discussion

  • Hemang Lavana
    Hemang Lavana
    2001-07-06

    • assigned_to: nobody --> andreas_kupries
     
  • Change, v0

     
    Attachments
    • assigned_to: andreas_kupries --> nobody
     
  • Logged In: YES
    user_id=75003

    Added a patch performing the requested change.

    Note that we must not change "exp_command.c".
    Here "exp_exit" is implemented and calling "exit"
    inside of that will result in an infinite recursion.

     
    • assigned_to: nobody --> andreas_kupries
     
  • Logged In: YES
    user_id=75003

    This patch was committed to "expect-sf418892-sf439042-
    branch".

     
    • status: open --> closed
     
  • Logged In: YES
    user_id=75003

    Merged to head.