Turi Create  4.0
process_util.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef PROCESS_UTIL_HPP
7 #define PROCESS_UTIL_HPP
8 
9 #include<string>
10 #include<boost/optional.hpp>
11 
12 namespace turi {
13 
14 /**
15  * \ingroup process_management
16  * Get the PID of my parent process.
17  */
18 size_t get_parent_pid();
19 
20 /**
21  * Get the PID of my current process.
22  */
23 size_t get_my_pid();
24 
25 /**
26  * \ingroup process_management
27  * Waits for a pid to exit.
28  * (The function is misnamed. This will work for all PIDs not just my parent)
29  */
30 void wait_for_parent_exit(size_t parent_pid);
31 
32 
33 /**
34  * \ingroup process_management
35  * Returns true if process is running
36  */
37 bool is_process_running(size_t pid);
38 
39 /**
40  * \ingroup process_management
41  * Returns the environment variable's value;
42  * Note: on windows, the length of the return
43  * value is limited to 65534.
44  */
45 boost::optional<std::string> getenv_str(const char* variable_name);
46 
47 } // namespace turi
48 #endif // PROCESS_UTIL_HPP
boost::optional< std::string > getenv_str(const char *variable_name)
size_t get_parent_pid()
bool is_process_running(size_t pid)
size_t get_my_pid()
void wait_for_parent_exit(size_t parent_pid)