Home | History | Annotate | Download | only in adb

Lines Matching full: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
150 class Subprocess {
152 Subprocess(const std::string& command, const char* terminal_type,
154 ~Subprocess();
162 // Sets up FDs, forks a subprocess, starts the subprocess manager thread,
166 // Start the subprocess manager thread. Consumes the subprocess, regardless of success.
168 static bool StartThread(std::unique_ptr<Subprocess> subprocess,
200 DISALLOW_COPY_AND_ASSIGN(Subprocess);
203 Subprocess::Subprocess(const std::string& command, const char* terminal_type,
210 // subprocess. PTYs automatically send SIGHUP to the slave-side process when the master side
217 D("Can't create raw subprocess without shell protocol, using PTY in raw mode instead");
223 Subprocess::~Subprocess() {
227 bool Subprocess::ForkAndExec(std::string* error) {
243 "failed to create pipe for subprocess error reporting: %s", strerror(errno));
301 // Raw subprocess + shell protocol allows for splitting stderr.
317 // Subprocess child.
348 // Subprocess parent.
349 D("subprocess parent: stdin/stdout FD = %d, stderr FD = %d",
352 // Wait to make sure the subprocess exec'd without error.
360 D("subprocess parent: exec completed");
383 // Don't let reads/writes to the subprocess block our thread. This isn't
385 // write a ton of data to stdin but the subprocess never reads it and
399 D("subprocess parent: completed");
403 bool Subprocess::StartThread(std::unique_ptr<Subprocess> subprocess, std::string* error) {
404 Subprocess* raw = subprocess.release();
407 android::base::StringPrintf("failed to create subprocess thread: %s", strerror(errno));
415 int Subprocess::OpenPtyChildFd(const char* pts_name, ScopedFd* error_sfd) {
449 void Subprocess::ThreadHandler(void* userdata) {
450 Subprocess* subprocess = reinterpret_cast<Subprocess*>(userdata);
453 "shell srvc %d", subprocess->pid()));
455 D("passing data streams for PID %d", subprocess->pid());
456 subprocess->PassDataStreams();
458 D("deleting Subprocess for PID %d", subprocess->pid());
459 delete subprocess;
462 void Subprocess::PassDataStreams() {
477 // Pass data until the protocol FD or both the subprocess pipes die, at
513 ScopedFd* Subprocess::SelectLoop(fd_set* master_read_set_ptr,
528 PLOG(ERROR) << "select failed, closing subprocess pipes";
569 ScopedFd* Subprocess::PassInput() {
608 // FD and risk losing subprocess output, leave it open.
640 ScopedFd* Subprocess::PassOutput(ScopedFd* sfd, ShellProtocol::Id id) {
644 // it just means the subprocess completed.
661 void Subprocess::WaitForExit() {
671 D("subprocess killed by signal %d", WTERMSIG(status));
674 D("subprocess didn't exit");
678 D("subprocess exit code = %d", WEXITSTATUS(status));
747 D("starting %s subprocess (protocol=%s, TERM=%s): '%s'",
752 auto subprocess = std::make_unique<Subprocess>(name, terminal_type, type, protocol);
753 if (!subprocess) {
754 LOG(ERROR) << "failed to allocate new subprocess";
755 return ReportError(protocol, "failed to allocate new subprocess");
759 if (!subprocess->ForkAndExec(&error)) {
760 LOG(ERROR) << "failed to start subprocess: " << error;
764 int local_socket = subprocess->ReleaseLocalSocket();
765 D("subprocess creation successful: local_socket_fd=%d, pid=%d", local_socket, subprocess->pid());
767 if (!Subprocess::StartThread(std::move(subprocess), &error)) {
768 LOG(ERROR) << "failed to start subprocess management thread: " << error;