The operating-system Module

The operating-system module is part of the System library. It provides an interface to some features of the host machine’s operating system.

Manipulating environment information

The operating-system module contains a number of interfaces for examining and specifying information about the operating system environment of the host machine. As well as providing constants that you can use in your code, you can examine and set the value of any environment variable in the system.

The following constants contain machine-specific information:

These constants contain information about the hardware and software resident on the host machine. The constants let you programmatically check the current system conditions before executing a piece of code.

The following function also returns information about the machine:

The following two functions let you manipulate the values of any environment variables in the system.

The following functions access information about the user logged on to the current machine, where available.

Manipulating application information

The operating-system module contains a number of functions for manipulating information specific to a given application, rather than the environment as a whole. You can run or quit any application, and interrogate the running application for application-specific information.

The operating-system module

This section contains a reference entry for each item exported from the System library’s operating-system module.

application-arguments Function

Returns the arguments passed to the running application.

Signature

application-arguments => arguments

Values
Discussion

Returns the arguments passed to the running application as a vector of instances of <byte-string>.

See also

application-filename Function

Returns the full filename of the running application.

Signature

application-filename => false-or-filename

Values
  • false-or-filename – An instance of false-or(<byte-string>).

Discussion

Returns the full filename (that is, the absolute pathname) of the running application, or #f if the filename cannot be determined.

Example

The following is an example of an absolute pathname naming an application:

"C:\\Program Files\\foo\\bar.exe"
See also

application-name Function

Returns the name of the running application.

Signature

application-name => name

Values
Discussion

Returns the name of the running application. This is normally the command name as typed on the command line and may be a non-absolute pathname.

Example

The following is an example of a non-absolute pathname used to refer to the application name:

"foo\\bar.exe"
See also

$architecture-little-endian? Constant

Constant specifying whether the processor architecture is little-endian.

Type

<boolean>

Discussion

This constant is a boolean value that is true if the processor architecture is little-endian and false if it is big-endian. (A processor is little-endian if the rightmost bit in a word is the least-significant bit.) For processors implementing the Intel x86 architecture this value is #t.

See also

current-process-id Function

Returns the integer value for the current process ID.

Signature

current-process-id => pid

Values
Discussion

Returns the integer value of the current process ID.

See also

environment-variable Function

Returns the value of a specified environment variable.

Signature

environment-variable name => value

Parameters
Values
Discussion

Returns the value of the environment variable specified by name, or #f if there is no such environment variable.

See also

environment-variable-setter Function

Sets the value of an environment variable.

Signature

environment-variable-setter new-value name => new-value

Parameters
Values
Discussion

Changes the value of the environment variable specified by name to new-value. If new-value is #f, the environment variable is undefined. If the environment variable does not already exist, environment-variable-setter creates it.

Note

Windows 95 places restrictions on the number of environment variables allowed, based on the total length of the names and values of the existing environment variables. The function environment-variable-setter only creates a new environment variable if it is possible within these restrictions. See the relevant Windows 95 documentation for more details.

See also

exit-application Function

Terminates execution of the running application.

Signature

exit-application status => ()

Parameters
Discussion

Terminates execution of the running application, returning the value of status to whatever launched the application, for example an MS-DOS window or Windows 95/NT shell.

Note

This function is also available from the dylan-extensions module in the dylan library and the common-extensions module of the common-dylan library.

See also

load-library Function

Loads a shared library into the current process.

Signature

load-library name => module

Parameters
Values
Discussion

Loads the library specified by name into the current process. The library must be a shared library.

If the library is a library written in Dylan, then when it loaded, constructor functions will run which set up the various methods and other Dylan objects within the shared library. Top level code within the library will be executed.

Load-time failures, for example due to missing files or unsatisfied symbol dependencies, will cause an <error> condition to be signaled.

Note

Dynamic loading of Dylan code is currently only supported on non-Windows platforms using the LLVM back-end, and on Windows using the HARP back-end.

login-name Function

Returns as an instance of <string> the name of the user logged on to the current machine, or #f if unavailable.

Signature

login-name () => name-or-false

Values
  • name-or-false – An instance of false-or(<string>).

Discussion

Returns as an instance of <string> the name of the user logged on to the current machine, or #f if unavailable.

See also

login-group Function
Signature

login-group () => group-or-false

Values
  • group-or-false – An instance of false-or(<string>).

Discussion

Returns as an instance of <string> the group (for example NT domain, or Windows Workgroup) of which the user logged on to the current machine is a member, or #f if the group is unavailable.

See also

$machine-name Constant

Constant specifying the type of hardware installed in the host machine.

Type

<symbol>

Value

#”x86”, #”x86-64”, #”ppc”

Discussion

This constant is a symbol that represents the type of hardware installed in the host machine.

See also

$os-name Constant

Constant specifying the operating system running on the host machine.

Type

<symbol>

Value

#”win32”, #”linux”, #”darwin”, #”freebsd”

Discussion

This constant is a symbol that represents the operating system running on the host machine.

See also

$os-variant Constant

Constant specifying which variant of an operating system the current machine is running, where relevant.

Type

<symbol>

Discussion

This constant is a symbol value distinguishing between variants of the operating system identified by $os-name, where relevant; otherwise it has the same value as $os-name. On Windows, the possible values are #"win3.1", #"win95", #"win98", and #"winnt".

See also

$os-version Constant

Constant specifying which version of an operating system the current machine is running.

Type

<string>

Discussion

The constant $os-version is a string value that identifies the version of the operating system. For Windows NT, a typical value would be “4.0.1381 Service Pack 3”. For Windows 95, a typical value would be “4.0.1212 B”.

See also

owner-name Function

Returns the name of the user who owns the current machine, if available.

Signature

owner-name () => name-or-false

Values
  • name-or-false – An instance of false-or(<string>).

Discussion

Returns as an instance of <string> the name of the user who owns the current machine (that is, the name entered when the machine was registered), or #f if the name is unavailable.

owner-organization Function

Returns the organization to which the user who owns the current machine belongs, if available.

Signature

owner-organization () => organization-or-false

Values
  • organization-or-false – An instance of false-or(<string>).

Discussion

Returns as an instance of <string> the organization to which the user who owns the current machine belongs, or #f if the name is unavailable.

parent-process-id Function

Returns the integer value for the parent process ID.

Signature

parent-process-id => pid

Values
Discussion

Returns the integer value of the parent process ID.

Note

This is not yet implemented on Windows.

See also

$platform-name Constant

Constant specifying the operating system running on and the type of hardware installed in the host machine.

Type

<symbol>

Value

#"x86-win32", #"x86-linux", etc.

Discussion

This constant is a symbol that represents the both the operating system running on, and the type of hardware installed in, the host machine. It is a combination of the $os-name and $machine-name constants.

Example

#"x86-win32", #"x86_64-linux"

See also

machine-concurrent-thread-count Function

Return the number of concurrent execution threads available.

Signature

machine-concurrent-thread-count => count

Values
Discussion

Returns the number of execution threads currently available. This normally corresponds to the number of logical processor cores currently online, and may vary over the lifetime of the program.

register-application-exit-function Function

Register a function to be executed when the application is about to exit.

Signature

register-application-exit-function function => ()

Parameters
Discussion

Register a function to be executed when the application is about to exit. The Dylan runtime will make sure that these functions are executed.

The function should not expect any arguments, nor expect that any return values be used.

Note

Currently, the registered functions will be invoked in the reverse order in which they were added. This is not currently a contractual guarantee and may be subject to change.

Note

This function is also available from the dylan-extensions module in the dylan library and the common-extensions module of the common-dylan library.

Example

See also

run-application Function

Launches an application using the specified name and arguments.

Signature

run-application command #key minimize? activate? under-shell? inherit-console? => status

Parameters
  • command – An instance of <string>.

  • minimize? (#key) – An instance of <boolean>.

  • activate? (#key) – An instance of <boolean>.

  • under-shell? (#key) – An instance of <boolean>.

  • inherit-console? (#key) – An instance of <boolean>.

Values
Discussion

Launches an application using the name and arguments specified in command. Using this function is equivalent to typing the command in a MS-DOS window. The return value is the exit status returned by the application.

If the minimize? keyword is #t, the command’s shell will appear minimized. It is #f by default.

If the activate? keyword is #t, the shell window becomes the active window. It is #t by default.

If the under-shell? keyword is #t, an MS-DOS shell is created to run the application; otherwise, the application is run directly. It is #f by default.

If the inherit-console? keyword is #t, the new application uses the same console window as the current application; otherwise, the new application is created with a separate console window. It is #t by default.

See also

tokenize-command-string Function

Parses a command line into a command name and arguments.

Signature

tokenize-command-string line => command #rest arguments

Parameters
Values
Discussion

Parses the command specified in line into a command name and arguments. The rules used to tokenize the string are given in Microsoft’s C/C++ reference in the section “Parsing C Command-Line Arguments”.

See also