2020-11-21 04:33:10 +00:00
|
|
|
using System;
|
2020-06-10 18:48:54 +00:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using Mono.Unix.Native;
|
|
|
|
|
|
|
|
namespace NzbDrone.Mono.Interop
|
|
|
|
{
|
|
|
|
internal sealed class SafeUnixHandle : SafeHandle
|
|
|
|
{
|
|
|
|
private SafeUnixHandle()
|
|
|
|
: base(new IntPtr(-1), true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public SafeUnixHandle(int fd)
|
|
|
|
: base(new IntPtr(-1), true)
|
|
|
|
{
|
|
|
|
handle = new IntPtr(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool IsInvalid
|
|
|
|
{
|
2020-11-21 04:33:10 +00:00
|
|
|
get { return handle == new IntPtr(-1); }
|
2020-06-10 18:48:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool ReleaseHandle()
|
|
|
|
{
|
2020-11-21 04:33:10 +00:00
|
|
|
return Syscall.close(handle.ToInt32()) != -1;
|
2020-06-10 18:48:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|