Functions to return the path of the current process image.
More...
#include <cerrno>
#include "pstore/support/error.hpp"
Go to the source code of this file.
|
|
std::string | pstore::process_file_name () |
| | Returns the path of the current process image.
|
| |
| template<typename ProcessPathFunction , typename BufferType > |
| std::size_t | pstore::process_file_name (ProcessPathFunction get_process_path, BufferType &buffer) |
| |
| template<typename SpanType , typename SysCtlFunction , typename BufferType > |
| std::size_t | pstore::freebsd::process_file_name (SpanType mib, SysCtlFunction ctl, BufferType &buffer) |
| | Returns the path of the current process on FreeBSD. More...
|
| |
Functions to return the path of the current process image.
◆ process_file_name() [1/2]
template<typename ProcessPathFunction , typename BufferType >
| std::size_t pstore::process_file_name |
( |
ProcessPathFunction |
get_process_path, |
|
|
BufferType & |
buffer |
|
) |
| |
- Template Parameters
-
| ProcessPathFunction | This should be a Callable type with a signature equivalent to std::function <std::size_t (gsl::span<char>)>. |
| BufferType | Should be a vector-like type which supports size(),capacity(),and resize() and should be convertable to gsl::span<char>. |
- Parameters
-
| get_process_path | A function which will be clled to retrieve the current process file name. It is passed a character span into which the result should be written. The return value is the number of characters places in that output buffer. |
| buffer | A vector-like object which, on return, will contain the process file name. |
- Returns
- The number of valid characters in the 'buffer' container.
◆ process_file_name() [2/2]
template<typename SpanType , typename SysCtlFunction , typename BufferType >
| std::size_t pstore::freebsd::process_file_name |
( |
SpanType |
mib, |
|
|
SysCtlFunction |
ctl, |
|
|
BufferType & |
buffer |
|
) |
| |
Returns the path of the current process on FreeBSD.
This function is a wrapper around the FreeBSD sysctl() function which, amongst other things, can be used to discover the path of a process given its ID.
- Note
- The function is exposed here to enable unit testing.
- Template Parameters
-
| BufferType | Should be a vector-like type which supports size(),capacity(),and resize() and should be convertable to gsl::span<char>. |
| SysCtlFunction | The sysctl() function or a replacement intended for unit testung. |
- Parameters
-
| mib | A command array which tells the sysctl() function what to do. |
| ctl | The real sysctl() function or mock implementation thereof. |
| buffer | A vector-like object which will hold the result of calling the 'ctl' function. |
- Returns
- The number of valid characters in the 'buffer' container.