NAME
Os – helper module for interfacing with the host OS

SYNOPSIS
include "os.m";
os := load Os Os–>PATH;
init:       fn();
filename: fn(name: string): string;
run: fn(cmd: string, dir: string): (string, string);
Cmdio: adt {
ifd: ref Sys–>FD;     # stdin
ofd: ref Sys–>FD;     # stdout
efd: ref Sys–>FD;     # stderr
wfd: ref Sys–>FD;     # wait
cfd: ref Sys–>FD;     # ctl
};
frun:       fn(cmd: string, dir: string): (ref Cmdio, string);
emuhost:    string;
emuroot:    string;

DESCRIPTION
Os provides operations common in most servers that export resources from the host OS. The module must be initialized by calling init before using any of its other facilities.

Filename returns a string for the file named name in a format understood by the underlying system. In particular, it takes care of adding the value of $emuhost as a prefix to the file name given. It is useful to execute host commands that refer to files known to us, but kept in the host file system.

Run executes cmd in the host system shell using dir as current directory and returns a tuple with the command output and an error string. The parameter dir may be nil, in which case the current directory is not changed for the command.

Frun provides is similar to run but returns file descriptors to let the caller stream input, output, errors, recover the process wait status, and issue control requests to the process. Upon errors frun returns a non–null error string and a null reference to a descriptor set.

Emuhost and Emuroot keep the value of the respective environment variables.

SOURCE
/usr/octopus/port/lib/os.b

SEE ALSO
cmd(3).