1 //===- llvm/System/Process.h ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Reid Spencer and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the llvm::sys::Process class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SYSTEM_PROCESS_H
15 #define LLVM_SYSTEM_PROCESS_H
17 #include "llvm/System/TimeValue.h"
22 /// This class provides an abstraction for getting information about the
23 /// currently executing process.
25 /// @brief An abstraction for operating system processes.
30 /// This static function will return the operating system's virtual memory
32 /// @returns The number of bytes in a virtual memory page.
34 /// @brief Get the virtual memory page size
35 static unsigned GetPageSize();
37 /// This static function will return the total amount of memory allocated
38 /// by the process. This only counts the memory allocated via the malloc,
39 /// calloc and realloc functions and includes any "free" holes in the
42 /// @brief Return process memory usage.
43 static size_t GetMallocUsage();
45 /// This static function will return the total memory usage of the
46 /// process. This includes code, data, stack and mapped pages usage. Notei
47 /// that the value returned here is not necessarily the Running Set Size,
48 /// it is the total virtual memory usage, regardless of mapped state of
50 static size_t GetTotalMemoryUsage();
52 /// This static function will set \p user_time to the amount of CPU time
53 /// spent in user (non-kernel) mode and \p sys_time to the amount of CPU
54 /// time spent in system (kernel) mode. If the operating system does not
55 /// support collection of these metrics, a zero TimeValue will be for both
57 static void GetTimeUsage(
59 ///< Returns the TimeValue::now() giving current time
61 ///< Returns the current amount of user time for the process
63 ///< Returns the current amount of system time for the process
66 /// This static function will return the process' current user id number.
67 /// Not all operating systems support this feature. Where it is not
68 /// supported, the function should return 65536 as the value.
69 static int GetCurrentUserId();
71 /// This static function will return the process' current group id number.
72 /// Not all operating systems support this feature. Where it is not
73 /// supported, the function should return 65536 as the value.
74 static int GetCurrentGroupId();
76 /// This function makes the necessary calls to the operating system to
77 /// prevent core files or any other kind of large memory dumps that can
78 /// occur when a program fails.
79 /// @brief Prevent core file generation.
80 static void PreventCoreFiles();
82 /// This function determines if the standard input is connected directly
83 /// to a user's input (keyboard probably), rather than coming from a file
85 static bool StandardInIsUserInput();
87 /// This function determines if the standard output is connected to a
88 /// "tty" or "console" window. That is, the output would be displayed to
89 /// the user rather than being put on a pipe or stored in a file.
90 static bool StandardOutIsDisplayed();
92 /// This function determines if the standard error is connected to a
93 /// "tty" or "console" window. That is, the output would be displayed to
94 /// the user rather than being put on a pipe or stored in a file.
95 static bool StandardErrIsDisplayed();