The second section of the buildfile starts with the [+script] attribute. This attribute informs mkifs that the specified file is a script file, a sequence of commands that you want the procnto process manager to execute when it has completed its own startup.
The script file can be external or inline, and its name is arbitrary, though QNX usually uses some variation on .script. Multiple scripts are concatenated into one and are interpreted in the order in which they appear.
Script files look just like regular shell scripts, but have the following differences:
You can use modifiers and attributes to control different aspects of command execution or environment. For example, you can use the [cpu=0] modifier to bind a particular command to CPU 0.
When you specify a modifier on a separate line, it applies to all subsequent commands. When you specify one on the same line as a command, it applies to that command only.
For a description of all available modifiers, see Script files in the mkifs documentation.
In this example, the script file is an inline file called .script, which contains the following:
sched_aps IOPKT 20 5 procmgr_symlink ../../proc/boot/libc.so /usr/lib/ldqnx.so.2 [pri=12] devc-ser8250-abc123 -F -e -c14745600 -b115200 0xc8000000 ^2,15 & reopen 5.0 /dev/ser1 display_msg Serial Driver Started
If we review this file, we find that the script:
As mentioned in Environment variables, the bootstrap file can set the _CS_PATH and _CS_LIBPATH configuration strings. You can set PATH, LD_LIBRARY_PATH, and other environment variables if the programs in your script need them.
Buildfile scripts support foreground and background processes. Just as in the shell, you can specify an ampersand (&) on the command line to make the program run in the background. If you run a program in the foreground and it doesn't exit, then the rest of the script is never executed, and the system might not become fully operational.
For a command to be run, its executable must be available when the script is executed. You can add the executable to the image, or get it from a filesystem that's started before the executable is required. Placing the executable in a filesystem reduces the size of the OS image.
You can use the [cpu=] attribute to instruct the procnto module to bind processes to a specific CPU core. The syntax for this attribute is like that of any value attribute: [attribute=value] filename. Use this attribute in one of the following ways:
At boot time, if there is no processor core with the specified index, procnto displays a warning message and launches the command with no runmask restrictions.
The script file stored on the target isn't the same as the original specification of the script file in the buildfile. This difference is because the script file on the target is not the original ASCII text: mkifs parses the text commands in the script file and stores only the parsed output on the target.
This design minimizes the work that the process manager has to do at runtime when it starts up and processes the script file — we didn't want to have to include a complete shell interpreter in the process manager!