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