• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_CORE_PLATFORM_SUBPROCESS_H_
17 #define TENSORFLOW_CORE_PLATFORM_SUBPROCESS_H_
18 
19 #include <memory>
20 #include <vector>
21 
22 namespace tensorflow {
23 
24 // Channel identifiers.
25 enum Channel {
26   CHAN_STDIN = 0,
27   CHAN_STDOUT = 1,
28   CHAN_STDERR = 2,
29 };
30 
31 // Specify how a channel is handled.
32 enum ChannelAction {
33   // Close the file descriptor when the process starts.
34   // This is the default behavior.
35   ACTION_CLOSE,
36 
37   // Make a pipe to the channel.  It is used in the Communicate() method to
38   // transfer data between the parent and child processes.
39   ACTION_PIPE,
40 
41   // Duplicate the parent's file descriptor. Useful if stdout/stderr should
42   // go to the same place that the parent writes it.
43   ACTION_DUPPARENT,
44 };
45 
46 // Supports spawning and killing child processes.
47 class SubProcess;
48 
49 // Returns an object that represents a child process that will be
50 // launched with the given command-line arguments `argv`. The process
51 // must be explicitly started by calling the Start() method on the
52 // returned object.
53 std::unique_ptr<SubProcess> CreateSubProcess(const std::vector<string>& argv);
54 
55 }  // namespace tensorflow
56 
57 #include "tensorflow/core/platform/platform.h"
58 
59 #if defined(PLATFORM_GOOGLE)
60 #include "tensorflow/core/platform/google/subprocess.h"
61 #elif defined(PLATFORM_POSIX) || defined(PLATFORM_POSIX_ANDROID) || \
62     defined(PLATFORM_GOOGLE_ANDROID)
63 #include "tensorflow/core/platform/posix/subprocess.h"
64 #elif defined(PLATFORM_WINDOWS)
65 #include "tensorflow/core/platform/windows/subprocess.h"
66 #else
67 #error Define the appropriate PLATFORM_<foo> macro for this platform
68 #endif
69 
70 #endif  // TENSORFLOW_CORE_PLATFORM_SUBPROCESS_H_
71