objc

Typedefs | Enumerations | Functions
Environment

System methods for reading information about the environment. More...

Collaboration diagram for Environment:

Typedefs

typedef void(* sys_env_signal_callback_t) (sys_env_signal_t signal)
 Callback function type for handling environment signals. More...
 

Enumerations

enum  sys_env_signal_t { SYS_ENV_SIGNAL_NONE = 0, SYS_ENV_SIGNAL_TERM, SYS_ENV_SIGNAL_INT, SYS_ENV_SIGNAL_QUIT = (1 << 2) }
 Environment signal types. More...
 

Functions

bool sys_env_signalhandler (sys_env_signal_t mask, sys_env_signal_callback_t callback)
 Sets a handler for environment signals. More...
 
const char * sys_env_serial (void)
 Returns a unique identifier for the current environment. More...
 
const char * sys_env_name (void)
 Returns the name of the current environment. More...
 
const char * sys_env_version (void)
 Returns the version of the current environment. More...
 

Detailed Description

System methods for reading information about the environment.

Typedef Documentation

◆ sys_env_signal_callback_t

typedef void(* sys_env_signal_callback_t) (sys_env_signal_t signal)

Callback function type for handling environment signals.

Parameters
signalThe type of signal that was received.

This typedef defines the signature for callback functions that handle environment signals. The callback receives a signal type parameter indicating which signal was received.

Definition at line 42 of file env.h.

Enumeration Type Documentation

◆ sys_env_signal_t

Environment signal types.

Enumeration of signal types that can be received from the environment or operating system. These signals typically indicate termination or interrupt requests that applications should handle gracefully.

Enumerator
SYS_ENV_SIGNAL_NONE 

No signal.

SYS_ENV_SIGNAL_TERM 

Termination signal (termination request from OS)

SYS_ENV_SIGNAL_INT 

Interrupt signal (interrupt request from user)

SYS_ENV_SIGNAL_QUIT 

Quit signal (quit request from user)

Definition at line 24 of file env.h.

24  {
27  (1 << 0),
29  (1 << 1),
30  SYS_ENV_SIGNAL_QUIT = (1 << 2),
Interrupt signal (interrupt request from user)
Definition: env.h:28
No signal.
Definition: env.h:25
sys_env_signal_t
Environment signal types.
Definition: env.h:24
Quit signal (quit request from user)
Definition: env.h:30
Termination signal (termination request from OS)
Definition: env.h:26

Function Documentation

◆ sys_env_name()

const char* sys_env_name ( void  )

Returns the name of the current environment.

Returns
The name of the current environment as a string, which is typically the name of the program or application that is running.
Examples:
examples/runtime/watchdog/main.c.

◆ sys_env_serial()

const char* sys_env_serial ( void  )

Returns a unique identifier for the current environment.

Returns
A serial number or unique identifier as a string.
Examples:
examples/runtime/watchdog/main.c.

◆ sys_env_signalhandler()

bool sys_env_signalhandler ( sys_env_signal_t  mask,
sys_env_signal_callback_t  callback 
)

Sets a handler for environment signals.

Parameters
maskBitmask of sys_env_signal_t values indicating which signals to handle. If zero, all signals are handled.
callbackThe callback function to handle signals, or NULL to disable signal handling.
Returns
true if the handler was set or cleared successfully, false if signals are not supported on this platform.

This function registers a callback function that will be invoked when the application receives environment signals such as termination requests (SIGTERM), interrupt signals (SIGINT), or quit signals (SIGQUIT). The callback allows applications to perform graceful shutdown procedures when requested.

Only one signal handler can be active at a time. Setting a new handler will replace any previously registered handler.

Not all platforms support all signal types. Embedded platforms may have limited or no signal support.

The signal handler may be called from interrupt context on some platforms. Keep the implementation simple and avoid blocking operations, memory allocation, or complex system calls within the callback.

See also
sys_env_signal_callback_t for callback function signature requirements.

◆ sys_env_version()

const char* sys_env_version ( void  )

Returns the version of the current environment.

Returns
The version of the current environment as a string, which is typically the version of the program or application that is running.