Home | History | Annotate | Download | only in adb

Lines Matching defs:Subprocess

21 // of communication with the subprocess, passing raw data or using a simple
33 // Non-protocol subprocesses work by passing subprocess stdin/out/err through
41 // Subprocess | adbd subprocess thread | adbd main fdevent loop
59 // Subprocess | adbd subprocess thread | adbd main fdevent loop
139 class Subprocess {
141 Subprocess(const std::string& command, const char* terminal_type,
143 ~Subprocess();
151 // Sets up FDs, forks a subprocess, starts the subprocess manager thread,
155 // Start the subprocess manager thread. Consumes the subprocess, regardless of success.
157 static bool StartThread(std::unique_ptr<Subprocess> subprocess,
189 DISALLOW_COPY_AND_ASSIGN(Subprocess);
192 Subprocess::Subprocess(const std::string& command, const char* terminal_type,
199 // subprocess. PTYs automatically send SIGHUP to the slave-side process when the master side
206 D("Can't create raw subprocess without shell protocol, using PTY in raw mode instead");
212 Subprocess::~Subprocess() {
223 bool Subprocess::ForkAndExec(std::string* error) {
239 "failed to create pipe for subprocess error reporting: %s", strerror(errno));
298 // Raw subprocess + shell protocol allows for splitting stderr.
314 // Subprocess child.
357 // Subprocess parent.
358 D("subprocess parent: stdin/stdout FD = %d, stderr FD = %d",
361 // Wait to make sure the subprocess exec'd without error.
369 D("subprocess parent: exec completed");
392 // Don't let reads/writes to the subprocess block our thread. This isn't
394 // write a ton of data to stdin but the subprocess never reads it and
408 D("subprocess parent: completed");
412 bool Subprocess::StartThread(std::unique_ptr<Subprocess> subprocess, std::string* error) {
413 Subprocess* raw = subprocess.release();
419 int Subprocess::OpenPtyChildFd(const char* pts_name, unique_fd* error_sfd) {
453 void Subprocess::ThreadHandler(void* userdata) {
454 Subprocess* subprocess = reinterpret_cast<Subprocess*>(userdata);
456 adb_thread_setname(android::base::StringPrintf("shell svc %d", subprocess->pid()));
458 D("passing data streams for PID %d", subprocess->pid());
459 subprocess->PassDataStreams();
461 D("deleting Subprocess for PID %d", subprocess->pid());
462 delete subprocess;
465 void Subprocess::PassDataStreams() {
480 // Pass data until the protocol FD or both the subprocess pipes die, at
515 unique_fd* Subprocess::SelectLoop(fd_set* master_read_set_ptr,
529 PLOG(ERROR) << "select failed, closing subprocess pipes";
570 unique_fd* Subprocess::PassInput() {
608 // FD and risk losing subprocess output, leave it open.
639 unique_fd* Subprocess::PassOutput(unique_fd* sfd, ShellProtocol::Id id) {
643 // it just means the subprocess completed.
660 void Subprocess::WaitForExit() {
670 D("subprocess killed by signal %d", WTERMSIG(status));
673 D("subprocess didn't exit");
677 D("subprocess exit code = %d", WEXITSTATUS(status));
730 D("starting %s subprocess (protocol=%s, TERM=%s): '%s'",
735 auto subprocess = std::make_unique<Subprocess>(name, terminal_type, type, protocol);
736 if (!subprocess) {
737 LOG(ERROR) << "failed to allocate new subprocess";
738 return ReportError(protocol, "failed to allocate new subprocess");
742 if (!subprocess->ForkAndExec(&error)) {
743 LOG(ERROR) << "failed to start subprocess: " << error;
747 unique_fd local_socket(subprocess->ReleaseLocalSocket());
748 D("subprocess creation successful: local_socket_fd=%d, pid=%d", local_socket.get(),
749 subprocess->pid());
751 if (!Subprocess::StartThread(std::move(subprocess), &error)) {
752 LOG(ERROR) << "failed to start subprocess management thread: " << error;