C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

19 Running and Debugging C and C++ Programs
Running Programs in the Guardian Environment
When you run a C or C++ program, the NonStop OS creates a new process from the program
file you specify. This new process passes through three phases of execution:
1. Program initialization: the C and C++ libraries and CRE perform startup tasks.
2. Program execution: the program controls the flow of execution.
3. Program termination: the C and C++ libraries and CRE perform shutdown tasks.
To run a C or C++ program in the Guardian environment, you use the command interpreter RUN
command. This diagram shows the general form of the RUN command. For more detail, see the
TACL Reference Manual.
[RUN] program-file [ / run-options / ] [ args-list ]
program-file
is the name of the C or C++ object file you want to run.
run-options
is a comma-separated list of options to the RUN command. Note that this list is enclosed by
slashes (/). Two of the most frequently used RUN options are IN and OUT.
IN file-name
specifies the standard input file (stdin) for the new process. If you do not include the IN
option, the new process uses the command interpreter's default input file, which is usually
your home terminal.
OUT file-name
specifies the standard output file (stdout) for the new process. If you do not include the
OUT option, the new process uses the command interpreter’s default output file, which is
usually your home terminal.
args-list
is a space-separated list of additional arguments to the C or C++ program you are running.
Note that you separate these arguments with spaces, not commas.
Usage Guidelines
To run in the Guardian environment a native object file that was compiled in the OSS
environment, you must set the file code to 700 for a TNS/R object file or 800 for a TNS/E
object file after copying the file to the Guardian file system.
For example, to set the file code of an object file to 700, enter this at a TACL prompt:
> FUP ALTER filename, CODE 700
To determine the file code of an object file, enter:
> FUP INFO filename
You can group several words into a single args-list argument by enclosing them in quotation
marks; for example:
5> RUN invite /OUT $s.#hold/ "Bruce and Rob"
To include a quotation mark as part of a quoted argument, use two quotation marks; for
example:
6> RUN findstr /IN myfile/ "Refer to ""Running a *"""
Running Programs in the Guardian Environment 319