The UnixMisc
interface provides miscellaneous Unix-related services.
INTERFACEUnixMisc ; IMPORT Ctypes, File, IP, OSError, Pathname, Ustat, Utypes, Word; TYPE SignalHandler = PROCEDURE (sig: Ctypes.int); PROCEDURE AppendAlways(file: File.T) RAISES {OSError.E};
Mark the underlying file descriptor so that writes always append to the end of the file.
PROCEDURE FStat(file: File.T; VAR statbuf: Ustat.struct_stat) RAISES {OSError.E};
Gets the status of the given file.
PROCEDURE GetHostAddrs(host: TEXT): REF ARRAY OF IP.Address;
Returns an array containing all of a host's IP addresses. Returns NIL if the name lookup fails. Not re-entrant.
PROCEDURE GetHostName(): TEXT RAISES {OSError.E};
Returns the host name as obtained from Unix.gethostname()
.
PROCEDURE GetLogin(): TEXT;
Returns the user's login name, or NIL
if it is not known.
PROCEDURE GetMode(path: Pathname.T): Utypes.mode_t RAISES {OSError.E};
Returns the file mode for the given file.
PROCEDURE GetUmask(): Utypes.mode_t;
Returns the umask setting.
PROCEDURE MapFile(p: Pathname.T; VAR statbuf: Ustat.struct_stat): ADDRESS RAISES {OSError.E};
Maps the given file into memory with a read-only shared mapping.
Fills in statbuf
with the status information of the file.
Returns the address of the mapped region. It is a checked runtime
error to attempt to map anything but a regular file.
PROCEDURE MaskMode(mode: Utypes.mode_t; umask := -1): Utypes.mode_t;
Returns the given mode, as modified by the umask
value. If it
is defaulted, then the program's umask setting is used.
PROCEDURE ReadLink(path: Pathname.T): TEXT RAISES {OSError.E};
Reads the given symbolic link and returns it as text.
<* EXTERNAL "setsid" *> PROCEDURE SetSID(): Utypes.pid_t;
Set session-ID.
<* EXTERNAL "UnixMiscSigIsIgnored" *> PROCEDURE SigIsIgnored(sig: Ctypes.int): BOOLEAN;
Reports whether a given signal is currently set up to be ignored.
<* EXTERNAL "UnixMiscSignal" *> PROCEDURE Signal(sig: Ctypes.int; func: SignalHandler): SignalHandler;
Like the standard C signal() function, except it disables thread scheduling when the handler is executing.
PROCEDURE Stat(path: Pathname.T; VAR statbuf: Ustat.struct_stat) RAISES {OSError.E};
Gets the status of the given file.
PROCEDURE Unmap(adr: ADDRESS; size: Word.T) RAISES {OSError.E};
Unmaps the given address range.
END UnixMisc.