Android-cuttlefish cvd tool
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
23
24namespace cuttlefish {
25
26// Success is defined by the exit code being `0`.
27Result<std::string> RunAndCaptureStdout(Command);
28
29/*
30 * Consumes a Command and runs it, optionally managing the stdio channels.
31 *
32 * If `stdin` is set, the subprocess stdin will be pipe providing its contents.
33 * If `stdout` is set, the subprocess stdout will be captured and saved to it.
34 * If `stderr` is set, the subprocess stderr will be captured and saved to it.
35 *
36 * If `command` exits normally, the lower 8 bits of the return code will be
37 * returned in a value between 0 and 255.
38 * If some setup fails, `command` fails to start, or `command` exits due to a
39 * signal, the return value will be negative.
40 */
41int RunWithManagedStdio(Command, const std::string* stdin, std::string* stdout,
42 std::string* stderr,
43 SubprocessOptions options = SubprocessOptions());
44
45} // namespace cuttlefish
int options
Definition: f2fscrypt.c:124
Definition: alloc_driver.h:20
Result< std::string > RunAndCaptureStdout(Command command)
Definition: managed_stdio.cc:147
int RunWithManagedStdio(Command cmd_tmp, const std::string *stdin_str, std::string *stdout_str, std::string *stderr_str, SubprocessOptions options)
Definition: managed_stdio.cc:54