blob: 0dcbef5f71a1cd765efc286aefc25e8785920bbd [file] [log] [blame]
Elly Jonesa44d22d2012-01-05 18:05:56 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Elly Jones00e439d2011-12-19 16:59:10 -05002// 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 Jones00e439d2011-12-19 16:59:10 -05007#include "process_with_id.h"
8
9namespace debugd {
10
Ben Chana0011d82014-05-13 00:19:29 -070011const char kTracepath[] = "/usr/sbin/tracepath";
Elly Jones00e439d2011-12-19 16:59:10 -050012
13TracePathTool::TracePathTool() { }
14TracePathTool::~TracePathTool() { }
15
Ben Chana0011d82014-05-13 00:19:29 -070016std::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-Jonesd9a16cd2012-11-12 16:09:49 -050021 ProcessWithId* p = CreateProcess(true);
Elly Jones00e439d2011-12-19 16:59:10 -050022 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 Chana0011d82014-05-13 00:19:29 -070036} // namespace debugd