iTP Secure WebServer System Administrator's Guide (iTPWebSvr 6.0+)

Using Common Gateway Interface (CGI) Programs
iTP Secure WebServer System Administrator’s Guide523346-002
8-34
Design Guidelines
Design Guidelines
Most CGI programs do not clean up their environments. Programs are written with the
assumption that the process exits upon completion of the HTTP request. Because
Pathway CGI programs are persistent, you should be aware of the following coding
considerations:
Code must be written to be serially reusable between invocations of CGI_main.
The CGI environment changes on each invocation of CGI_main. To access your
environment variables, use CGI_initialize(), as follows:
1. Write a CGI_initialize() routine in your CGI program.
2. In this routine, call getenv(). This returns the current environment variable.
3. In your CGI_main routine, call getenv() again. This call returns the
WebServer’s environment variables.
You need to watch for memory leaks and file-open leaks.
State information should not be maintained in the server.