Previous Contents Next
Chapter 21 The unix library: Unix system calls

The unix library makes many Unix system calls and system-related library functions available to Objective Caml programs. This chapter describes briefly the functions provided. Refer to sections 2 and 3 of the Unix manual for more details on the behavior of these functions.

Not all functions are provided by all Unix variants. If some functions are not available, they will raise Invalid_arg when called.

Programs that use the unix library must be linked as follows:
        ocamlc other options unix.cma other files
        ocamlopt other options unix.cmxa other files
For interactive use of the unix library, do:
        ocamlmktop -o mytop unix.cma
        ./mytop
or (if dynamic linking of C libraries is supported on your platform), start ocaml and type #load "unix.cma";;.

  MacOS:
A fairly complete emulation of the Unix system calls is provided in the MacOS version of Objective Caml. The end of this chapter gives more information on the functions that are not supported under MacOS.
  Windows:
A fairly complete emulation of the Unix system calls is provided in the Windows version of Objective Caml. The end of this chapter gives more information on the functions that are not supported under Windows.


  MacOS:
Under MacOS, the Unix library is only available in the toplevel application, not in MPW tools. Below is a list of the functions that are not implemented, or only partially implemented, under MacOS. Functions not mentioned are fully implemented and behave as described previously in this chapter.
Functions Comment
chown, fchown not implemented
chroot not implemented
environment, putenv not implemented
execv, execve, execvp, execvpe not implemented
fork not implemented, use threads
getegid, geteuid, getgid, getuid always return 1
getgrnam, getgrgid not implemented
getlogin returns the user name as set in the Internet control panel
getpid returns the low-order 31 bits of the PSN
getppid not implemented
getpwnam, getpwuid not implemented
kill not implemented
link not implemented
mkfifo not implemented
nice not implemented
setgid, setuid not implemented
times only the process user time is returned
umask not implemented
wait not implemented
waitpid not implemented
establish_server not implemented; use threads
terminal functions (tc*) not implemented
  Windows:
The Cygwin port of Objective Caml fully implements all functions from the Unix module. The native Win32 port implements a subset of them. Below is a list of the functions that are not implemented, or only partially implemented, by the Win32 port. Functions not mentioned are fully implemented and behave as described previously in this chapter.
Functions Comment
fork not implemented, use create_process or threads
wait not implemented, use waitpid
waitpid can only wait for a given PID, not any child process
getppid not implemented (meaningless under Windows)
nice not implemented
in_channel_of_descr does not work on sockets under Windows 95, 98, ME; works fine under NT and 2000
out_channel_of_descr ditto
truncate, ftruncate not implemented
lstat, fstat not implemented
link, symlink, readlink not implemented (no links under Windows)
fchmod not implemented
chown, fchown not implemented (make no sense on a DOS file system)
umask not implemented
set_nonblock, clear_nonblock implemented as dummy functions; use threads instead of non-blocking I/O
rewinddir not implemented; re-open the directory instead
mkfifo not implemented
select implemented, but works only for sockets; use threads if you need to wait on other kinds of file descriptors
lockf not implemented
kill, pause not implemented (no inter-process signals in Windows)
alarm, times not implemented
getitimer, setitimer not implemented
getuid, getgid always return 1
getgid, getegid, getgroups not implemented
setuid, setgid not implemented
getpwnam, getpwuid always raise Not_found
getgrnam, getgrgid always raise Not_found
type socket_domain the domain PF_UNIX is not supported; PF_INET is fully supported
establish_server not implemented; use threads
terminal functions (tc*) not implemented

Previous Contents Next