Android-cuttlefish cvd tool
subprocess_managed_stdio.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <string>
19
22
23namespace cuttlefish {
24
25// Success is defined by the exit code being `0`.
26Result<std::string> RunAndCaptureStdout(Command);
27
28/*
29 * Consumes a Command and runs it, optionally managing the stdio channels.
30 *
31 * If `stdin` is set, the subprocess stdin will be pipe providing its contents.
32 * If `stdout` is set, the subprocess stdout will be captured and saved to it.
33 * If `stderr` is set, the subprocess stderr will be captured and saved to it.
34 *
35 * If `command` exits normally, the lower 8 bits of the return code will be
36 * returned in a value between 0 and 255.
37 * If some setup fails, `command` fails to start, or `command` exits due to a
38 * signal, the return value will be negative.
39 */
40int RunWithManagedStdio(Command, const std::string* stdin, std::string* stdout,
41 std::string* stderr,
42 SubprocessOptions options = SubprocessOptions());
43
44} // namespace cuttlefish
Definition: alloc_utils.cpp:23
Result< std::string > RunAndCaptureStdout(Command command)
Definition: subprocess_managed_stdio.cc:143
int RunWithManagedStdio(Command cmd_tmp, const std::string *stdin_str, std::string *stdout_str, std::string *stderr_str, SubprocessOptions options)
Definition: subprocess_managed_stdio.cc:54