API
Collaboration diagram for System utilities:

Modules

 System utility files
 

Functions

int MagAOX::sys::runCommand (std::vector< std::string > &commandOutput, std::vector< std::string > &commandStderr, std::vector< std::string > &commandList)
 Runs a command (with parameters) passed in using fork/exec. More...
 
int MagAOX::sys::th_seteuid (uid_t euid)
 Sets the effective user id of the calling thread, rather than the whole process. More...
 

Detailed Description

Function Documentation

◆ runCommand()

int MagAOX::sys::runCommand ( std::vector< std::string > &  commandOutput,
std::vector< std::string > &  commandStderr,
std::vector< std::string > &  commandList 
)

Runs a command (with parameters) passed in using fork/exec.

New process is made with fork(), and child runs execvp with command provided.

Original code by C. Bohlman for sysMonitor, then promoted to libMagAOX for general use.

Returns
0 on success
-1 on error
Parameters
[out]commandOutputthe output, line by line. If an error, first entry contains the message.
[out]commandStderrthe output of stderr.
[in]commandListcommand to be run, with one entry per command line word

Definition at line 22 of file runCommand.cpp.

Referenced by MagAOX::app::sysMonitor::findChronyStatus(), MagAOX::app::sysMonitor::findCPULoads(), MagAOX::app::sysMonitor::findCPUTemperatures(), MagAOX::app::sysMonitor::findDiskUsage(), and MagAOX::app::sysMonitor::findRamUsage().

◆ th_seteuid()

int MagAOX::sys::th_seteuid ( uid_t  euid)

Sets the effective user id of the calling thread, rather than the whole process.

Uses the syscall directly so that only the calling thread has modified privileges.

Ref: http://man7.org/linux/man-pages/man2/seteuid.2.html

Returns
0 on success
-1 on error, and errno is set
Parameters
[in]euidthe desired new effective user id

Definition at line 18 of file thSetuid.cpp.

Referenced by thSetuid_test::SCENARIO(), MagAOX::app::MagAOXApp< _useINDI >::setEuidCalled(), and MagAOX::app::MagAOXApp< _useINDI >::setEuidReal().