src/utils/system_utils/src/system_utils.c
int ADUC_SystemUtils_ExecuteShellCommand(const char* command)
{
    if (command == NULL || command[0] == '\0')
    {
        Log_Error("ExecuteShellCommand failed: command is empty");
        return EINVAL;
    }

    Log_Info("Execute shell command: %s", command);

    const int status = system(command); // NOLINT(cert-env33-c)
    if (status == -1)
    {
        Log_Error("ExecuteShellCommand failed: System call failed, errno = %d", errno);

        return errno;
    }

    // WIFEXITED returns zero if the child process terminated abnormally.
    if (!WIFEXITED(status))
    {
        Log_Error("ExecuteShellCommand failed: Command exited abnormally");

        return ECANCELED;
    }

    // if child process terminated normally, WEXITSTATUS returns its exit status value.
    const int executeStatus = WEXITSTATUS(status);

    // A shell command which exits with a zero exit status has succeeded. A non-zero exit status indicates failure.
    if (executeStatus != 0)
    {
        Log_Error("ExecuteShellCommand failed: Command exited with non-zero value, exitStatus = %d", executeStatus);

        return executeStatus;
    }

    return 0;
}
/**
 * @brief Execute shell command.
 *
 * @param command The command to execute as a string.
 * @return 0 for success.
 * @return non-zero status code for failure.
 *
 * The return value is an errno code for system call failures. If all system calls succeed,
 * the return value is the termination status of the child shell used to execute command.
 */
@brief Execute shell command.
@param command The command to execute as a string.
@return 0 for success.
@return non-zero status code for failure.

The return value is an errno code for system call failures. If all system calls succeed,
the return value is the termination status of the child shell used to execute command.
@brief Execute shell command . @param command The command to execute as a string . @return 0 for success . @return non - zero status code for failure . The return value is an errno code for system call failures . If all system calls succeed the return value is the termination status of the child shell used to execute command .
int ADUC_SystemUtils_ExecuteShellCommand(const char* command)
{
    if (command == NULL || command[0] == '\0')
    {
        Log_Error("ExecuteShellCommand failed: command is empty");
        return EINVAL;
    }
    Log_Info("Execute shell command: %s", command);
    const int status = system(command); 
    if (status == -1)
    {
        Log_Error("ExecuteShellCommand failed: System call failed, errno = %d", errno);
        return errno;
    }
    if (!WIFEXITED(status))
    {
        Log_Error("ExecuteShellCommand failed: Command exited abnormally");
        return ECANCELED;
    }
    const int executeStatus = WEXITSTATUS(status);
    if (executeStatus != 0)
    {
        Log_Error("ExecuteShellCommand failed: Command exited with non-zero value, exitStatus = %d", executeStatus);
        return executeStatus;
    }
    return 0;
}
int ADUC_SystemUtils_ExecuteShellCommand ( const char * command ) { if ( command == NULL || command [ 0 ] == ' \0 ' ) { Log_Error ( " " ) ; return EINVAL ; } Log_Info ( " " , command ) ; const int status = system ( command ) ; if ( status == -1 ) { Log_Error ( " " , errno ) ; return errno ; } if ( ! WIFEXITED ( status ) ) { Log_Error ( " " ) ; return ECANCELED ; } const int executeStatus = WEXITSTATUS ( status ) ; if ( executeStatus != 0 ) { Log_Error ( " " , executeStatus ) ; return executeStatus ; } return 0 ; }
@brief Execute shell command.
@brief Execute shell command .
// NOLINT(cert-env33-c) // WIFEXITED returns zero if the child process terminated abnormally. // if child process terminated normally, WEXITSTATUS returns its exit status value. // A shell command which exits with a zero exit status has succeeded. A non-zero exit status indicates failure.