Running shell scripts at exit

You can invoke an arbitrary shell script when your program exits or otherwise terminates by using the -run-at-exit option. For example, you can use a script to move or remove log files or view files, to note test failure, or to interact with PureCoverage data.

In addition to the %V, %v, and %p conversion characters, you can use these conversion characters:

Character

Converts to

%z

The string value "true" or "false" indicating whether any call chains were printed, for example, in error or leak reports

%x

The program's exit status (0 if the program did not call exit)

%e

The number of distinct access errors printed

%E

The total number of error occurrences noted

%l

The number of bytes of memory leaked

%L

The number of bytes of memory potentially leaked

 

Use the %z sequence to have your exit script act conditionally when Purify finds something of interest to you. If a call chain is printed in an access error, a memory leak, or as a result of calling purify_printf_with_call_chain(), the string is true; otherwise, it is false.

For example, if you set the option:

setenv PURIFYOPTIONS '-run-at-exit="if %z ; then \
     echo \"%v: %e errors, %l+%L bytes leaked.\" ; fi"'

When your program exits, you might see on stdout:

testprog: 2 errors, 1+10 bytes leaked.

If your program is running in the Viewer, Purify sends any command output to the X Window where you started the Viewer.