blob: c24bcb87c07b83c3ad264f83d4e3a5fe4ce64329 [file] [log] [blame]
Reid Spencer46189572004-12-23 21:16:46 +00001//===- lib/Debugger/FDHandle.cpp - File Descriptor Handle -----------------===//
Reid Spencer55cf0a62004-12-22 10:24:55 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Reid Spencer46189572004-12-23 21:16:46 +000010// This file implements a class for ensuring that Unix file handles get closed.
Reid Spencer55cf0a62004-12-22 10:24:55 +000011//
12//===----------------------------------------------------------------------===//
13
14#include "FDHandle.h"
15#include <unistd.h>
16
17using namespace llvm;
18
19//===----------------------------------------------------------------------===//
20// FDHandle class implementation
21//
22
23FDHandle::~FDHandle() throw() {
24 if (FD != -1)
25 ::close(FD);
26}
27
28FDHandle &FDHandle::operator=(int fd) throw() {
29 if (FD != -1)
30 ::close(FD);
31 FD = fd;
32 return *this;
33}