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]commandOutput[out] the output, line by line. If an error, first entry contains the message.
[out]commandStderr[out] the output of stderr.
[in]commandList[in] command 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::findDiskTemperature(), MagAOX::app::sysMonitor::findDiskUsage(), MagAOX::app::sysMonitor::findRamUsage(), and MagAOX::app::cacaoInterface::tmuxSendKeys().

◆ 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]euid[in] the desired new effective user id

Definition at line 18 of file thSetuid.cpp.

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