Mono.Unix Namespace

High-level Unix wrapper types.


The Mono.Unix namespace contains high-level wrapper classes, which provide .NET naming and usage conventions over the low-level Mono.Unix.Native.Syscall and Mono.Unix.Native.Stdlib functionality.

If an exception is generated due to an operating system-level error (as opposed to invalid arguments or some fully managed reason), the exception thrown will either inherit from Mono.Unix.UnixIOException, or the Exception.InnerException property will be a type inheriting from UnixIOException. In either case, the Mono.Unix.UnixIOException.ErrorCode property will contain the underlying error number that generated the exception. This error number can be used to look up additional information if necessary.


Thread-safety wasn't considered in the original Unix API. While some degree of thread-safety is provided from managed code, it is impossible to provide full thread-safety for interactions between managed and unmanaged code. For example, if you DllImport into a C library which uses non-thread-safe Unix functions which are also exposed in Mono.Unix, you may have threading issues including, but not limited to, memory corruption.

An effort is made to provide thread-safety from managed code, but it is impossible to know all dependencies for all potential Unix-like platforms. For example, is Mono.Unix.Native.Stdlib.fopen thread-safe? It appears to be under glibc, but isn't necessarily under all Unix platforms. Mono.Unix.Native.Stdlib assumes that it is. Only obviously unsafe exports are actually synchronized from managed code, such as Mono.Unix.Native.Stdlib.tmpnam and Mono.Unix.Native.Stdlib.strerror.

Documentation is based upon the FreeBSD man pages, which is under the following copyright:

FreeBSD Copyright Example

Copyright (c) 1980, 1983, 1986, 1991, 1993
    The Regents of the University of California.  All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
   must display the following acknowledgement:
    This product includes software developed by the University of
    California, Berkeley and its contributors.
4. Neither the name of the University nor the names of its contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.


AbstractUnixEndPointA System.Net.EndPoint implementation for abstract UNIX sockets as network addresses.
CatalogA wrapper to the libintl library providing message translation capabilities.
FileAccessPatternPossible operating system hints for future file data access.
FileAccessPermissionsUnix file access permissions.
FileHandleOperationsOperations that can be performed on a file handle.
FileSpecialAttributesUnix file special attributes.
FileTypesUnix filesystem types.
PeerCredWhen using Unix domain sockets (via Mono.Unix.UnixEndPoint or Mono.Unix.UnixClient, for example) most operating systems support the passing of credentials through the socket. Generally, the process id (PID) of the application on the other side of the connection as well as the group ID (GID) and user ID (UID) of the executing user are available. This is done via the kernel and cannot be spoofed, so this can be used to reliably authenticate a Unix socket connection.
StdioFileStreamA System.IO.Stream wrapper over the FILE type.
UnixClientA class to provide client connections to Unix domain socket servers.
UnixDirectoryInfoRepresents information about a directory in the filesystem.
UnixDriveInfoRepresents information about Unix volumes.
UnixDriveTypePossible Mono.Unix.UnixDriveInfo.DriveType values.
UnixEncodingA Unix filename System.Text.Encoding.
UnixEndPointA System.Net.EndPoint implementation for UNIX sockets as network addresses.
UnixEnvironmentProvides the current settings for, and information about, the execution environment.
UnixFileInfoProvides information and performs operations on files.
UnixFileSystemInfoProvides information and performs operations on file system entries.
UnixGroupInfoProvides information about a Unix group.
UnixIOExceptionRepresents errors that are generated from Unix system calls.
UnixListenerDocumentation for this section has not yet been entered.
UnixMarshal Provides a collection of miscellaneous methods for marshaling strings, allocating memory, and interoperating with the operating system.
UnixPath Performs operations on string instances that contain file or directory path information.
UnixPipesProvides information about a Unix pipe.
UnixProcess Provides information about a Unix process.
UnixSignal Represents the number of times a Unix signal has been emitted.
UnixStreamA System.IO.Stream wrapper over Unix file descriptors.
UnixSymbolicLinkInfo Provides information about and performs operations on symbolic links.
UnixUserInfoProvides information about a Unix user.