blob: 532a9a196bc05c89706e7550bad3575dc74ef9ef [file] [log] [blame]
Elly Jones00e439d2011-12-19 16:59:10 -05001// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
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
12namespace debugd {
13
14const char* kTracepath = "/usr/sbin/tracepath";
15
16TracePathTool::TracePathTool() { }
17TracePathTool::~TracePathTool() { }
18
19std::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) {
24 ProcessWithId* p = CreateProcess();
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