25. Runtime
- Method
exit
voidexit(intreturncode,void|stringfmt,mixed...extra)- Description
Exit the whole Pike program with the given
returncode.Using
exit()with any other value than0(zero) indicates that something went wrong during execution. See your system manuals for more information about return codes.The arguments after the
returncodewill be used for a call towerrorto output a message on stderr.- See also
_exit()
- Method
_exit
void_exit(intreturncode)- Description
This function does the same as
exit, but doesn't bother to clean up the Pike interpreter before exiting. This means that no destructors will be called, caches will not be flushed, file locks might not be released, and databases might not be closed properly.Use with extreme caution.
- See also
exit()
- Method
atexit
voidatexit(function(:void)callback)- Description
This function puts the
callbackin a queue of callbacks to call when pike exits. The call order is reversed, i.e. callbacks that have been added earlier are called aftercallback.- Note
Please note that
atexitcallbacks are not called if Pike exits abnormally.- See also
exit(),_exit()
- Method
trace
inttrace(intlevel,void|stringfacility,void|intall_threads)- Description
This function changes the trace level for the subsystem identified by
facilitytolevel. Iffacilityis zero or left out, it changes the global trace level which affects all subsystems.Enabling tracing causes messages to be printed to stderr. A higher trace level includes the output from all lower levels. The lowest level is zero which disables all trace messages.
See the -t command-line option for more information.
- Parameter
level If
facilityis specified then there is typically only one trace level for it, i.e. it's an on-or-off toggle. The global trace levels, whenfacilityisn't specified, are:1Trace calls to Pike functions and garbage collector runs.
2Trace calls to builtin functions.
3Trace every interpreted opcode.
4Also trace the opcode arguments.
- Parameter
facility Valid facilities are:
"gc"Trace the doings of the garbage collector. The setting is never thread local.
levelhas two different meanings:- 1..2
Trace the start and end of each gc run.
- 3..
Additionally show info about the collected garbage, to aid hunting down garbage problems. This currently shows gc'd trampolines. Note that the output can be very bulky and is somewhat low-level technical. Also note that pike currently has to be configured with
--with-rtldebugto enable this.
- Parameter
all_threads Trace levels are normally thread local, so changes affect only the current thread. To change the level in all threads, pass a nonzero value in this argument.
- Returns
The old trace level in the current thread is returned.
- Method
backtrace
array(Pike.BacktraceFrame) backtrace(int|voidflags)- Description
Get a description of the current call stack.
- Parameter
flags A bit mask of flags affecting generation of the backtrace.
Currently a single flag is defined:
1Return
LiveBacktraceFrames. This flag causes the frame objects to track changes (as long as they are in use), and makes eg local variables for functions available for inspection or change.Note that since these values are "live", they may change or dissapear at any time unless the corresponding thread has been halted or similar.
- Returns
The description is returned as an array with one entry for each call frame on the stack.
The entries are represented by
Pike.BacktraceFrameobjects.The current call frame will be last in the array.
- Note
Please note that the frame order may be reversed in a later version of Pike to accommodate for deferred backtraces.
- Note
Note that the arguments reported in the backtrace are the current values of the variables, and not the ones that were at call-time. This can be used to hide sensitive information from backtraces (eg passwords).
- Note
In old versions of Pike the entries used to be represented by arrays of the following format:
Array stringfileA string with the filename if known, else zero.
intlineAn integer containing the linenumber if known, else zero.
function(:void)funThe function that was called at this level.
mixed|void...argsThe arguments that the function was called with.
The above format is still supported by eg
describe_backtrace().- See also
catch(),throw()
- Method
gc
intgc(mapping|array|voidquick)- Description
Force garbage collection.
- Parameter
quick Perform a quick garbage collection on just this value, which must have been made weak by
set_weak_flag(). All values that only have a single reference fromquickwill then be freed.When
quickhasn't been specified or isUNDEFINED, this function checks all the memory for cyclic structures such as arrays containing themselves and frees them if appropriate. It also frees up destructed objects and things with only weak references.Normally there is no need to call this function since Pike will call it by itself every now and then. (Pike will try to predict when 20% of all arrays/object/programs in memory is 'garbage' and call this routine then.)
- Returns
The amount of garbage is returned. This is the number of arrays, mappings, multisets, objects and programs that had no nonweak external references during the garbage collection. It's normally the same as the number of freed things, but there might be some difference since _destruct() functions are called during freeing, which can cause more things to be freed or allocated.
- See also
Pike.gc_parameters,Debug.gc_status
- Method
query_num_arg
intquery_num_arg()- Description
Returns the number of arguments given when the previous function was called.
This is useful for functions that take a variable number of arguments.
- See also
call_function()