Hitachi

Job Management Partner 1 Version 10 Job Management Partner 1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide


3.10.1 How to forcibly terminate jobs

Organization of this subsection

(1) How to forcibly terminate a job

There are two ways to forcibly terminate a job:

When a job is forcibly terminated, the job controller forcibly terminates its child or descendant process that are executing. For details, see (2) Forcibly terminating child or descendant processes.

After forcibly terminating the child or descendant process, the job controller performs postprocessing on the allocated files, and then terminates the job without executing any subsequent job steps or commands. The job controller does not execute a subsequent job step even if abnormal or always is specified in its run attribute. In UNIX, when a job is forcibly terminated, the adshexec command terminates with an error by signal. For details about the job processing in UNIX when SIGTERM is received, see 3.10.2 Processing when signals are received (UNIX only). For details about the job processing in Windows when jobs are forcibly terminated, see 3.10.3 Job processing during forced termination (Windows only).

Important note

In Windows, when the adshexec command is started, the adshexecsub command is also started, and when the adshexec command is forcibly terminated, the adshexecsub command is also terminated. Therefore, do not forcibly terminate the adshexecsub command. If an attempt is made to forcibly terminate the adshexecsub command, the following events might occur:

  • A descendant process that is executing might not terminate.

  • Temporary files might remain in the system.

If these events occur, use the taskkill command or the task manager to forcibly terminate the descendant process and delete the temporary files manually.

Important note

Because JP1/Advanced Shell in a Windows environment uses job objects to forcibly terminate descendant processes, note the following;

  • A descendant process generated from JP1/Advanced Shell cannot be associated with a job object.

  • If a process of JP1/Advanced Shell has already been associated with a job object, forced termination of the job will not terminate the process generated by the child process of JP1/Advanced Shell.

Important note

In Windows, if a job that executes an external command and generates a child process is terminated forcibly and more than 255 processes that are at its grandchild or lower levels exist concurrently, the KNAX6381-E message might be issued and renaming of the spool job directory might fail. Note the following three points about this:

  • To reference a spool job directory that has failed, use the directory name displayed in the immediately following KNAX6382-I message that is issued.

  • A spool job directory whose renaming has failed cannot be deleted by the adshhk command. If necessary, delete it manually.

  • In the case of a job that has failed in renaming a spool job directory in the execution environment, job definition script operation information is not output by the adshevtout command.

(2) Forcibly terminating child or descendant processes

If a job is forcibly terminated, the job controller forcibly terminates its child or descendant processes, and then terminates the job.

(a) In UNIX

How child or descendant processes are forcibly terminated depends on the job input mode, as described in the following:

  • Terminal input mode

    SIGTERM is sent only to the child processes of the adshexec command. SIGTERM is not sent to any of the descendant processes of the adshexec command, including grandchild processes. If you want to perform postprocessing on these processes, use one of the following methods to create and execute a job:

    • If the user creates external commands, design the external commands to perform postprocessing on the descendant processes, for example, by automatically sending SIGTERM also to the descendant processes after SIGTERM is received.

    • When a job is forcibly terminated in the terminal input mode, not only the adshexec command but all the descendant processes, including grandchild processes, are subject to operations such as Ctrl + C and Ctrl + \.

    If grandchild processes remain after forced termination, use the ps command to obtain the process IDs of the remaining processes, and then manually terminate them with the kill command.

  • Non-terminal input mode

    SIGTERM is sent to the descendant processes of the adshexec command.

(b) In Windows

The TerminateProcess and TerminateJobObject functions are used to forcibly terminate the descendant processes of the adshexec command. The forced termination method is the same regardless of the job input mode.

(3) Notes about operations including Ctrl+C (UNIX only)

If a job is executed in the non-terminal input mode, operation such as Ctrl + C and Ctrl + \ might not be able to terminate simultaneously the root job, child jobs, and other external commands that were started.# If you wish to forcibly terminate these jobs and commands all at once, use the kill command to send a termination request signal such as SIGTERM to the root job immediately under the login shell.

#

If a job is executed in the non-terminal input mode, the adshexec command's process and its child processes belong to separate process groups. Therefore, if an operation such as Ctrl + C or Ctrl + \ is performed from the login shell while the job is executing, SIGINT or SIGQUIT is sent only to the process group currently running in the foreground.

The jobs and external commands running as descendant processes of the job that received the signal are forcibly terminated, but those jobs and external commands running as higher processes, including the parent process, are not forcibly terminated.