0

I am looking at source code for android and came across the following code:

unique_fd local_end(sfd[0]);
unique_fd remote_end(sfd[1]);
sfd[0] = sfd[1] = -1;

// dump blocks until completion, so spawn a thread..
std::thread dump_thread([=, remote_end { std::move(remote_end) }]() mutable {
           int err = service->dump(remote_end.get(), args);

           // It'd be nice to be able to close the remote end of the socketpair before the dump
           // call returns, to terminate our reads if the other end closes their copy of the
          // file descriptor, but then hangs for some reason. There doesn't seem to be a good
          // way to do this, though.
          remote_end.reset();

          if (err != 0) {
              aerr << "Error dumping service info: (" << strerror(err) << ") " << service_name << endl;
          }
});

Now, I don't understand what does this part mean:

[=, remote_end { std::move(remote_end) }]

Can someone please explain this?

Keselme
  • 3,779
  • 7
  • 36
  • 68

0 Answers0