Elly Jones | a44d22d | 2012-01-05 18:05:56 -0500 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Elly Jones | 00e439d | 2011-12-19 16:59:10 -0500 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "tracepath_tool.h" |
| 6 | |
| 7 | #include <map> |
| 8 | #include <string> |
| 9 | |
| 10 | #include "process_with_id.h" |
| 11 | |
| 12 | namespace debugd { |
| 13 | |
| 14 | const char* kTracepath = "/usr/sbin/tracepath"; |
| 15 | |
| 16 | TracePathTool::TracePathTool() { } |
| 17 | TracePathTool::~TracePathTool() { } |
| 18 | |
| 19 | std::string TracePathTool::Start(const DBus::FileDescriptor& outfd, |
| 20 | const std::string& destination, |
| 21 | const std::map<std::string, DBus::Variant>& |
| 22 | options, |
| 23 | DBus::Error& error) { |
Elly Fong-Jones | d9a16cd | 2012-11-12 16:09:49 -0500 | [diff] [blame^] | 24 | ProcessWithId* p = CreateProcess(true); |
Elly Jones | 00e439d | 2011-12-19 16:59:10 -0500 | [diff] [blame] | 25 | if (!p) |
| 26 | return ""; |
| 27 | p->AddArg(kTracepath); |
| 28 | if (options.count("numeric") == 1) { |
| 29 | p->AddArg("-n"); |
| 30 | } |
| 31 | p->AddArg(destination); |
| 32 | p->BindFd(outfd.get(), STDOUT_FILENO); |
| 33 | p->BindFd(outfd.get(), STDERR_FILENO); |
| 34 | LOG(INFO) << "tracepath: running process id: " << p->id(); |
| 35 | p->Start(); |
| 36 | return p->id(); |
| 37 | } |
| 38 | |
| 39 | }; // namespace debugd |