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 | |
Elly Jones | 00e439d | 2011-12-19 16:59:10 -0500 | [diff] [blame] | 7 | #include "process_with_id.h" |
| 8 | |
| 9 | namespace debugd { |
| 10 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame^] | 11 | const char kTracepath[] = "/usr/sbin/tracepath"; |
Elly Jones | 00e439d | 2011-12-19 16:59:10 -0500 | [diff] [blame] | 12 | |
| 13 | TracePathTool::TracePathTool() { } |
| 14 | TracePathTool::~TracePathTool() { } |
| 15 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame^] | 16 | std::string TracePathTool::Start( |
| 17 | const DBus::FileDescriptor& outfd, |
| 18 | const std::string& destination, |
| 19 | const std::map<std::string, DBus::Variant>& options, |
| 20 | DBus::Error* error) { |
Elly Fong-Jones | d9a16cd | 2012-11-12 16:09:49 -0500 | [diff] [blame] | 21 | ProcessWithId* p = CreateProcess(true); |
Elly Jones | 00e439d | 2011-12-19 16:59:10 -0500 | [diff] [blame] | 22 | if (!p) |
| 23 | return ""; |
| 24 | p->AddArg(kTracepath); |
| 25 | if (options.count("numeric") == 1) { |
| 26 | p->AddArg("-n"); |
| 27 | } |
| 28 | p->AddArg(destination); |
| 29 | p->BindFd(outfd.get(), STDOUT_FILENO); |
| 30 | p->BindFd(outfd.get(), STDERR_FILENO); |
| 31 | LOG(INFO) << "tracepath: running process id: " << p->id(); |
| 32 | p->Start(); |
| 33 | return p->id(); |
| 34 | } |
| 35 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame^] | 36 | } // namespace debugd |