4 Making Control Scripts and Commands DRD-Safe

This chapter describes the type of logic a packager or developer should look for to determine if a given control script or command is DRD-safe. For each of the following descriptions (sections), a set of examples and suggestions on how to make the control script or commands DRD-safe are provided.

Note:

Control scripts and commands are executing in a runcmd environment if the SW_SESSION_IS_DRD environment variable is set to 1.

4.1 Control Scripts Stopping, Starting or Restarting Processes/Daemons

Control scripts stopping, starting or restarting processes/daemonsany use of kill, init script, or invocation of any command that accepts a parameter of start, stop, or restartare suspect. While the use of kill_named_procs is safe, its behavior in a runcmd environment is different (see A.1 HP-UX 11i v2 control_utils).

Unsafe Examples:

kill -9 $PID

/sbin/init.d/comsec start

vxdctl stop >/dev/null 2>&1

init q

inetd -c

Suggested Resolutions:

Follow the steps below to make the logic DRD-safe:

1.If the logic is in a configure control script, no action is required. There are no DRD restrictions on configure scripts, which are executed during the boot of the system image rather than in the runcmd environment.

2.If the logic is part of a control script and is stopping a process, use the control_util

kill_named_procs to stop the process because that control utility is DRD-safe. (That is, if running in a runcmd environment, it does not kill the process.)

3.If the logic is in a checkinstall, preinstall, or postinstall control script, and it can be moved to the configure script, move it to the configure script.

4.If none of the above solutions fit the situation, detect that the command is running in a runcmd environment using the SW_SESSION_IS_DRD environment variable, and change the logic to be DRD-safe. In many cases this may mean skipping the stopping, starting, or restarting of the process/daemon: When the files on the inactive system image are being updated, the daemon running from the original system does not need to be stopped and restarted. Though this is a likely solution, the packager must make the assessment of whether it will work for a particular package.

Safe Examples:

[[ $SW_SESSION_IS_DRD != 1 ]] && kill -9 $PID

if [[ $SW_SESSION_IS_UPDATE -ne 1 && $SW_SESSION_IS_DRD –ne 1 ]] then

/sbin/init.d/comsec start fi