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
137 class Subprocess {
139 Subprocess(const std::string& command, const char* terminal_type,
141 ~Subprocess();
149 // Sets up FDs, forks a subprocess, starts the subprocess manager thread,
153 // Start the subprocess manager thread. Consumes the subprocess, regardless of success.
155 static bool StartThread(std::unique_ptr<Subprocess> subprocess,
187 DISALLOW_COPY_AND_ASSIGN(Subprocess);
190 Subprocess::Subprocess(const std::string& command, const char* terminal_type,
197 // subprocess. PTYs automatically send SIGHUP to the slave-side process when the master side
204 D("Can't create raw subprocess without shell protocol, using PTY in raw mode instead");
210 Subprocess::~Subprocess() {
214 bool Subprocess::ForkAndExec(std::string* error) {
230 "failed to create pipe for subprocess error reporting: %s", strerror(errno));
288 // Raw subprocess + shell protocol allows for splitting stderr.
304 // Subprocess child.
338 // Subprocess parent.
339 D("subprocess parent: stdin/stdout FD = %d, stderr FD = %d",
342 // Wait to make sure the subprocess exec'd without error.
350 D("subprocess parent: exec completed");
373 // Don't let reads/writes to the subprocess block our thread. This isn't
375 // write a ton of data to stdin but the subprocess never reads it and
389 D("subprocess parent: completed");
393 bool Subprocess::StartThread(std::unique_ptr<Subprocess> subprocess, std::string* error) {
394 Subprocess* raw = subprocess.release();
397 android::base::StringPrintf("failed to create subprocess thread: %s", strerror(errno));
405 int Subprocess::OpenPtyChildFd(const char* pts_name, unique_fd* error_sfd) {
439 void Subprocess::ThreadHandler(void* userdata) {
440 Subprocess* subprocess = reinterpret_cast<Subprocess*>(userdata);
443 "shell srvc %d", subprocess->pid()));
445 D("passing data streams for PID %d", subprocess->pid());
446 subprocess->PassDataStreams();
448 D("deleting Subprocess for PID %d", subprocess->pid());
449 delete subprocess;
452 void Subprocess::PassDataStreams() {
467 // Pass data until the protocol FD or both the subprocess pipes die, at
502 unique_fd* Subprocess::SelectLoop(fd_set* master_read_set_ptr,
516 PLOG(ERROR) << "select failed, closing subprocess pipes";
557 unique_fd* Subprocess::PassInput() {
595 // FD and risk losing subprocess output, leave it open.
626 unique_fd* Subprocess::PassOutput(unique_fd* sfd, ShellProtocol::Id id) {
630 // it just means the subprocess completed.
647 void Subprocess::WaitForExit() {
657 D("subprocess killed by signal %d", WTERMSIG(status));
660 D("subprocess didn't exit");
664 D("subprocess exit code = %d", WEXITSTATUS(status));
733 D("starting %s subprocess (protocol=%s, TERM=%s): '%s'",
738 auto subprocess = std::make_unique<Subprocess>(name, terminal_type, type, protocol);
739 if (!subprocess) {
740 LOG(ERROR) << "failed to allocate new subprocess";
741 return ReportError(protocol, "failed to allocate new subprocess");
745 if (!subprocess->ForkAndExec(&error)) {
746 LOG(ERROR) << "failed to start subprocess: " << error;
750 unique_fd local_socket(subprocess->ReleaseLocalSocket());
751 D("subprocess creation successful: local_socket_fd=%d, pid=%d", local_socket.get(),
752 subprocess->pid());
754 if (!Subprocess::StartThread(std::move(subprocess), &error)) {
755 LOG(ERROR) << "failed to start subprocess management thread: " << error;