NAME
Solaris::ProcessContract::Template - Manage a Solaris process contract template instance via libcontract
SYNOPSIS
# Create a fresh template
my $template = $pc->template();
# Set behaviors flags for this template
$template->set_parameters( CT_PR_NOORPHAN );
# Set event monitoring flags for this template
$template->set_informative_events( CT_PR_EV_FORK );
$template->set_fatal_events( CT_PR_EV_CORE|CT_PR_EV_HWERR );
$template->set_critical_events( CT_PR_EV_HWERR );
# Activate this template, so that it will be used the next time we create a
# child process
$pc->template->activate();
# Stop using this template, so that we go bach to the default behavior of
# creating child processes in our own contract
$pc->template->clear();
DESCRIPTION
The process contract template allows you to define which contract the next child process you create will use.
By default, child processes are created in the same contract as the parent.
By settings up and then "activating" a template, you are telling solaris to use a different contract with those settings the next time a process is created.
It will continue to create new contracts with that template for every process you fork, until you call "clear". That returns you to the original behavior of creating new processes in the same contract as your parent.
Calls to "activate" and "clear" are aware of which process they are called from. For example, calling "clear" from the parent process will set that behavior for only the parent, the child contract will still continue to use that template to create new contracts until you call "clear" from the child process as well.
METHODS
new
Use the "get_template" in Solaris::ProcessContract method to create a new instance of this object instead of calling this yourself.
my $template = $pc->get_template();
activate
Arguments: none
Returns: undef
Activate this template so that it will be used the next time a new child process is created.
$template->activate();
This method is context aware, so it will only affect the process that you call it from. See "DESCRIPTION" for more information.
clear
Arguments: none
Returns: undef
Clear this template so that it will no longer be used for the next child process that is created.
$template->clear();
This method is context aware, so it will only affect the process that you call it from. See "DESCRIPTION" for more information.
set_parameters
Arguments: $flags
Returns: undef
Set the behavior parameter $flags
on this template.
# Set one flag
$template->set_parameters( CT_PR_PGRPONLY );
# Set multiple flags
$template->set_parameters( CT_PR_INHERIT|CT_PR_PGRPONLY );
# Unset all flags
$template->set_parameters( 0 );
This allows you to control the behavior of the next contract that will be created.
See "Param Flags" in Solaris::ProcessContract for a list of available parameter flags and what they do.
None of the parameter flags are set by default, so you only need to set this if you wish to change the template behavior.
get_parameters
Arguments: none
Returns: $flags
Gets the current parameter $flags
that are set on this template.
See "set_parameters".
set_informative_events
Arguments: $flags
Returns: undef
Set the informative events $flags
on this template.
# Set one flag
$template->set_informative_events( CT_PR_EV_FORK );
# Set multiple flags
$template->set_informative_events( CT_PR_EV_FORK|CT_PR_EV_EXIT|CT_PR_EV_CORE );
# Unset all flags
$template->set_informative_events( 0 );
This allows you to control which events will be reported for this contract group.
If you do not set this value yourself, "CT_PR_EV_CORE" and "CT_PR_EV_SIGNAL" will be used as the default informative events.
See "Event Flags" in Solaris::ProcessContract for a list of available event flags.
get_informative_events
Arguments: none
Returns: $flags
Returns the current informative events $flags
that are set on this template.
set_fatal_events
Arguments: $flags
Returns: undef
Set the fatal events $flags
on this template.
# Set one flag
$template->set_fatal_events( CT_PR_EV_EMPTY );
# Set multiple flags
$template->set_fatal_events( CT_PR_EV_HWERR|CT_PR_EV_CORE );
# Unset all flags
$template->set_fatal_events( 0 );
This allows you to control which events will cause all processes in the contract to be automatically killed.
See "Event Flags" in Solaris::ProcessContract for a list of available event flags.
If you do not set this value yourself, "CT_PR_EV_EMPTY" and "CT_PR_EV_HWERR" will be used as the default informative events.
get_fatal_events
Arguments: none
Returns: $flags
Returns the current fatal events $flags
that are set on this template.
See "set_fatal_events".
set_critical_events
Arguments: $flags
Returns: undef
Set the critical events $flags
on this template.
# Set one flag
$template->set_fatal_events( CT_PR_EV_EMPTY );
# Set multiple flags
$template->set_fatal_events( CT_PR_EV_HWERR|CT_PR_EV_CORE );
# Unset all flags
$template->set_fatal_events( 0 );
This allows you to control which events will cause both this contract and any ones related to it to be destroyed.
See "Event Flags" in Solaris::ProcessContract for a list of available event flags.
If you do not set this value yourself "CT_PR_EV_HWERR" will be used as the default informative event.
get_critical_events
Arguments: none
Returns: $flags
Returns the current critical events $flags
that are set on this template.
reset
Arguments: none
Returns undef
If you wish to start over with a fresh template, but don't want to destroy the one you have and create a new instance, use "reset"" in " to start this template over.
Alternately, you could just set your template instance to undef
and then run "template" in Solaris::ProcessContract in Solaris::ProcessContract to get a new one.
SEE ALSO
AUTHOR
Danny Warren