Testing
After any program source code update, it is always necessary to validate it for proper operation. That validation should be carried out in the expected operational environments. The following sections describe how to set up environments with large PIDs or with a large number of processes in order to adequately validate updates to support such environments.
Testing Large PIDs
To validate that programs properly handle large PID values,
Testing Large Numbers of Processes
To validate that programs properly handle large numbers of processes requires that a small program be written to create lots of processes. The program being validated can then be executed once those processes are created. The following example is an outline of such a program:
//sample program to create 50626 processes
//the program can be stopped by sending
//SIGTERM signal to main process
sig_handler() {
relay SIGTERM to all my child procs exit
}
create_children() level++
if (level < 4) {
setsid() // start new process group and session for 15 iterations {
fork()
if child { create_children()
}
if parent {
record child pid for later
}
}
for 15 iterations {
//children will exit on SIGTERM wait() for children
}
exit
}
5Except for certain kernel system processes, which always have very low PID values.
6For some programs, it may be valuable to also test in environments where some PID values are very small and some are very large. For these, create some test processes before and after increasing process_id_min, and don’t reboot before completing the tests.
10