Contents
Overview: Env program
The system program Env
is intended for setting startup parameters and environment variables of programs. If the Env
program is included in a solution, the processes connected via IPC channel to the Env
process will automatically send IPC requests to this program and receive startup parameters and environment variables when these processes are started.
Use of the Env
system program is an outdated way of setting startup parameters and environment variables of programs. Instead, you must set the startup parameters and environment variables of programs via the init.yaml.in
or init.yaml
file.
If the value of a startup parameter or environment variable of a program is defined through the Env
program and via the init.yaml.in
or init.yaml
file, the value defined through the Env
program will be applied.
To use the Env
program in a solution, you need to do the following:
- Develop the code of the
Env
program using the macros and functions from the header filesysroot-*-kos/include/env/env.h
from the KasperskyOS SDK. - Build the executable file of the
Env
program by linking it to theenv_server
library from the KasperskyOS SDK. - In the init description, indicate that the
Env
process must be started and connected to other processes (Env
acts as a server in this case). The name of the IPC channel is assigned by theENV_SERVICE_NAME
macro defined in the header fileenv.h
. - Include the
Env
executable file in the solution image.
Source code of the Env program
The source code of the Env
program utilizes the following macros and functions from the header file env.h
:
ENV_REGISTER_ARGS(name,argarr)
sets theargarr
startup parameters for the program that will run in the context of thename
process.ENV_REGISTER_VARS(name,envarr)
sets theenvarr
environment variables for the program that will run in the context of thename
process.ENV_REGISTER_PROGRAM_ENVIRONMENT(name,argarr,envarr)
sets theargarr
startup parameters andenvarr
environment variables for the program that will run in the context of thename
process.envServerRun()
initializes the server part of theEnv
program so that it can respond to IPC requests.