SIGTERM Handling - Basic Teradata Query

Basic Teradata Query Reference

Product
Basic Teradata Query
Release Number
15.10
Language
English (United States)
Last Update
2018-10-07
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

UNIX/Linux BTEQ processes can be killed by issuing a kill command from another process. In order to give BTEQ the ability to gracefully exit and set a non-0 return code for its own process, the kill must send a trappable SIGTERM signal rather than a non-trappable SIGKILL signal. Either of the following variations of the kill command (where "PID" is replaced with the actual process id for the instance of bteq) will cause a trappable SIGTERM to be sent:

    kill PID
    kill -15 PID

Example  

SIGTERM issued when BTEQ is idle (such as not waiting on CLI for some SQL response):

    BTEQ -- Enter your SQL request or BTEQ command:
    SELECT date;
    SELECT date;
    *** Query completed. One row found. One column returned.
    *** Total elapsed time was 1 second.
        Date
    --------
    13/05/06
    BTEQ -- Enter your SQL request or BTEQ command:
    <<< SIGTERM trapped here >>>
    *** Exiting BTEQ...
    *** RC (return code) = 16

Example  

SIGTERM issued when BTEQ is waiting on CLI for some SQL response:

    BTEQ -- Enter your SQL request or BTEQ command:
    SELECT * FROM dbc.tables a, dbc.tables b, dbc.tables c;
    SELECT * FROM dbc.tables a, dbc.tables b, dbc.tables c;
    <<< SIGTERM trapped here >>>
    *** Exiting BTEQ Because Of Terminate Signal...
    *** RC (return code) = 16

Note: A SIGTERM signal is different than SIGKILL signal. While BTEQ traps the SIGTERM signal and exits with a non-0 severity, a SIGKILL signal cannot be trapped and BTEQ process will terminate abruptly. BTEQ’s return code upon SIGKILL will be system defined which is usually 265 for any process that is killed using SIGKILL.

A SIGKILL signal can be issued by running following command:

    kill -9 PID

Example  

SIGKILL issued when BTEQ is waiting on CLI for some SQL response:

    BTEQ -- Enter your SQL request or BTEQ command:
    SELECT * FROM dbc.tables a, dbc.tables b, dbc.tables c;
    SELECT * FROM dbc.tables a, dbc.tables b, dbc.tables c;
    <<< SIGKILL issued here, non-trappable >>>
    Killed