GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
runtrap(8) runtools runtrap(8)

runtrap - run a program with a signal trapper

runtrap [-hV] id trapper program [ args ... ]

runtrap starts program with any args and monitors it as a long-running process. If runtrap notices that program terminates, it restarts it.

Whenever runtrap itself receives any signal it can catch, it invokes the argument given by trapper in this form:

trapper ``trap'' id pid signum signame

Where:

trapper

The name of an executable specified in the trapper argument on the command-line.

``trap''

The verbatim string ``trap''.

id

A simple string specified in the id argument on the command-line.

pid

The process ID of the program that runtrap is monitoring.

signum

The numeric decimal representation of the signal received by runtrap.

signame

The symbolic name for the signal received by runtrap.

Presumably trapper is a short-running program designed to perform some special handling of signals destined for program. After invoking trapper, runtrap waits for it to complete and then resumes monitoring program.

If runtrap receives a SIGTERM, it flags itself to terminate. It then invokes trapper as above with SIGTERM arguments. When program terminates, runtrap itself then exits normally.

-h
Help. Print a brief usage message to stderr and exit.
-V
Version. Print the version number to stderr and exit.

runtrap is designed for use in perpetrate(5) runscripts for services that need special signal handling. The example below shows how an rc.main runscript may be multiplexed to handle ``trap'' targets:

#!/bin/sh
exec 2>&1
TARGET=${1}
SVNAME=${2}
start() {
  echo "starting ${SVNAME} ..."
  exec runtrap ${SVNAME} ./rc.main /usr/sbin/foo -f
}
reset() {
  echo "resetting ${SVNAME} ..."
  #...
}
trap() {
  SVPID=${3}
  SIGNUM=${4}
  SIGNAME=${5}
  echo "trapping ${SVNAME} for signal ${SIGNAME} ..."
  kill -${SIGNUM} ${SVPID}
} 
eval ${TARGET} "$@"
### EOF

Wayne Marshall, http://b0llix.net/perp/

runtools_intro(8), runargs(8), runargv0(8), runchoom(8), rundetach(8), rundeux(8), runenv(8), runfile(8), runlimit(8), runlock(8), runpause(8), runsession(8), runtool(8), runuid(8), perpd(8), perpetrate(5)
January 2013 runtools-2.07

Search for    or go to Top of page |  Section 8 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.