summaryrefslogtreecommitdiffstats
path: root/tools/android/forwarder2/common.cc
blob: ddd8c52b806977463ae3d0bde507ae9a9f1eee43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "tools/android/forwarder2/common.h"

#include <errno.h>
#include <unistd.h>

#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "base/posix/safe_strerror.h"

namespace forwarder2 {

void PError(const char* msg) {
  LOG(ERROR) << msg << ": " << base::safe_strerror(errno);
}

void CloseFD(int fd) {
  const int errno_copy = errno;
  if (IGNORE_EINTR(close(fd)) < 0) {
    PError("close");
    errno = errno_copy;
  }
}

}  // namespace forwarder2