class Process

Declaration

class Process { /* full declaration omitted */ };

Description

A collection of legacy interfaces for querying information about the current executing process.

Declared at: llvm/include/llvm/Support/Process.h:43

Method Overview

Methods

static bool AreCoreFilesPrevented()

Description

true if PreventCoreFiles has been called, false otherwise.

Declared at: llvm/include/llvm/Support/Process.h:96

static bool ColorNeedsFlush()

Description

Whether changing colors requires the output to be flushed. This is needed on systems that don't support escape sequences for changing colors.

Declared at: llvm/include/llvm/Support/Process.h:189

static void Exit(int RetCode,
                 bool NoCleanup = false)

Description

Equivalent to ::exit(), except when running inside a CrashRecoveryContext. In that case, the control flow will resume after RunSafely(), like for a crash, rather than exiting the current process. Use

Declared at: llvm/include/llvm/Support/Process.h:216

Parameters

int RetCode
bool NoCleanup = false

static void ExitNoCleanup(int RetCode)

Declared at: llvm/include/llvm/Support/Process.h:219

Parameters

int RetCode

static bool FileDescriptorHasColors(int fd)

Description

This function determines if the given file descriptor is displayd and supports colors.

Declared at: llvm/include/llvm/Support/Process.h:154

Parameters

int fd

static bool FileDescriptorIsDisplayed(int fd)

Description

This function determines if the given file descriptor is connected to a "tty" or "console" window. That is, the output would be displayed to the user rather than being put on a pipe or stored in a file.

Declared at: llvm/include/llvm/Support/Process.h:150

Parameters

int fd

static Optional<std::string> FindInEnvPath(
    llvm::StringRef EnvName,
    llvm::StringRef FileName,
    ArrayRef<std::string> IgnoreList,
    char Separator = EnvPathSeparator)

Description

This function searches for an existing file in the list of directories in a PATH like environment variable, and returns the first file found, according to the order of the entries in the PATH like environment variable. If an ignore list is specified, then any folder which is in the PATH like environment variable but is also in IgnoreList is not considered.

Declared at: llvm/include/llvm/Support/Process.h:108

Parameters

llvm::StringRef EnvName
llvm::StringRef FileName
ArrayRef<std::string> IgnoreList
char Separator = EnvPathSeparator

static Optional<std::string> FindInEnvPath(
    llvm::StringRef EnvName,
    llvm::StringRef FileName,
    char Separator = EnvPathSeparator)

Declared at: llvm/include/llvm/Support/Process.h:113

Parameters

llvm::StringRef EnvName
llvm::StringRef FileName
char Separator = EnvPathSeparator

static std::error_code
FixupStandardFileDescriptors()

Declared at: llvm/include/llvm/Support/Process.h:121

static Optional<std::string> GetEnv(
    llvm::StringRef name)

Declared at: llvm/include/llvm/Support/Process.h:100

Parameters

llvm::StringRef name

static size_t GetMallocUsage()

Description

Return process memory usage. This static function will return the total amount of memory allocated by the process. This only counts the memory allocated via the malloc, calloc and realloc functions and includes any "free" holes in the allocated space.

Declared at: llvm/include/llvm/Support/Process.h:75

static unsigned int GetRandomNumber()

Description

Get the result of a process wide random number generator. The generator will be automatically seeded in non-deterministic fashion.

Declared at: llvm/include/llvm/Support/Process.h:210

static void GetTimeUsage(
    TimePoint<>& elapsed,
    std::chrono::nanoseconds& user_time,
    std::chrono::nanoseconds& sys_time)

Description

This static function will set \p user_time to the amount of CPU time spent in user (non-kernel) mode and \p sys_time to the amount of CPU time spent in system (kernel) mode. If the operating system does not support collection of these metrics, a zero duration will be for both values.

Declared at: llvm/include/llvm/Support/Process.h:85

Parameters

TimePoint<>& elapsed
Returns the system_clock::now() giving current time
std::chrono::nanoseconds& user_time
Returns the current amount of user time for the process
std::chrono::nanoseconds& sys_time
Returns the current amount of system time for the process

static const char* OutputBold(bool bg)

Description

Same as OutputColor, but only enables the bold attribute.

Declared at: llvm/include/llvm/Support/Process.h:199

Parameters

bool bg

static const char* OutputColor(char c,
                               bool bold,
                               bool bg)

Description

This function returns the colorcode escape sequences. If ColorNeedsFlush() is true then this function will change the colors and return an empty escape sequence. In that case it is the responsibility of the client to flush the output stream prior to calling this function.

Declared at: llvm/include/llvm/Support/Process.h:196

Parameters

char c
bool bold
bool bg

static const char* OutputReverse()

Description

This function returns the escape sequence to reverse forground and background colors.

Declared at: llvm/include/llvm/Support/Process.h:203

static void PreventCoreFiles()

Description

This function makes the necessary calls to the operating system to prevent core files or any other kind of large memory dumps that can occur when a program fails. Prevent core file generation.

Declared at: llvm/include/llvm/Support/Process.h:93

static const char* ResetColor()

Description

Resets the terminals colors, or returns an escape sequence to do so.

Declared at: llvm/include/llvm/Support/Process.h:206

static std::error_code SafelyCloseFileDescriptor(
    int FD)

Declared at: llvm/include/llvm/Support/Process.h:130

Parameters

int FD

static unsigned int StandardErrColumns()

Description

This function determines the number of columns in the window if standard error is connected to a "tty" or "console" window. If standard error is not connected to a tty or console, or if the number of columns cannot be determined, this routine returns zero.

Declared at: llvm/include/llvm/Support/Process.h:168

static bool StandardErrHasColors()

Description

This function determines whether the terminal connected to standard error supports colors. If standard error is not connected to a terminal, this function returns false.

Declared at: llvm/include/llvm/Support/Process.h:178

static bool StandardErrIsDisplayed()

Description

This function determines if the standard error is connected to a "tty" or "console" window. That is, the output would be displayed to the user rather than being put on a pipe or stored in a file.

Declared at: llvm/include/llvm/Support/Process.h:145

static bool StandardInIsUserInput()

Description

This function determines if the standard input is connected directly to a user's input (keyboard probably), rather than coming from a file or pipe.

Declared at: llvm/include/llvm/Support/Process.h:135

static unsigned int StandardOutColumns()

Description

This function determines the number of columns in the window if standard output is connected to a "tty" or "console" window. If standard output is not connected to a tty or console, or if the number of columns cannot be determined, this routine returns zero.

Declared at: llvm/include/llvm/Support/Process.h:161

static bool StandardOutHasColors()

Description

This function determines whether the terminal connected to standard output supports colors. If standard output is not connected to a terminal, this function returns false.

Declared at: llvm/include/llvm/Support/Process.h:173

static bool StandardOutIsDisplayed()

Description

This function determines if the standard output is connected to a "tty" or "console" window. That is, the output would be displayed to the user rather than being put on a pipe or stored in a file.

Declared at: llvm/include/llvm/Support/Process.h:140

static void UseANSIEscapeCodes(bool enable)

Description

Enables or disables whether ANSI escape sequences are used to output colors. This only has an effect on Windows. Note: Setting this option is not thread-safe and should only be done during initialization.

Declared at: llvm/include/llvm/Support/Process.h:184

Parameters

bool enable

static Expected<unsigned int> getPageSize()

Description

Get the process's page size. This may fail if the underlying syscall returns an error. In most cases, page size information is used for optimization, and this error can be safely discarded by calling consumeError, and an estimated page size substituted instead.

Declared at: llvm/include/llvm/Support/Process.h:55

static unsigned int getPageSizeEstimate()

Description

Get the process's estimated page size. This function always succeeds, but if the underlying syscall to determine the page size fails then this will silently return an estimated page size. The estimated page size is guaranteed to be a power of 2.

Declared at: llvm/include/llvm/Support/Process.h:61

static llvm::sys::Process::Pid getProcessId()

Description

Get the process's identifier.

Declared at: llvm/include/llvm/Support/Process.h:48