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
Envprogram using the macros and functions from the header filesysroot-*-kos/include/env/env.hfrom the KasperskyOS SDK. - Build the executable file of the
Envprogram by linking it to theenv_serverlibrary from the KasperskyOS SDK. - In the init description, indicate that the
Envprocess must be started and connected to other processes (Envacts as a server in this case). The name of the IPC channel is assigned by theENV_SERVICE_NAMEmacro defined in the header fileenv.h. - Include the
Envexecutable 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 theargarrstartup parameters for the program that will run in the context of thenameprocess.ENV_REGISTER_VARS(name,envarr)sets theenvarrenvironment variables for the program that will run in the context of thenameprocess.ENV_REGISTER_PROGRAM_ENVIRONMENT(name,argarr,envarr)sets theargarrstartup parameters andenvarrenvironment variables for the program that will run in the context of thenameprocess.envServerRun()initializes the server part of theEnvprogram so that it can respond to IPC requests.