diff6-10.chapter21.txtこのページは最後に更新されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。 last mod. 2008-08-28 (木) 09:57:02
22,27d21 < 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. < 29,32c23,25 < 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. --- > 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. 42a36 > 46d39 < 462,466c455,457 < The type of error codes. Errors defined in the POSIX standard < and additional errors from UNIX98 and BSD. All other errors < are mapped to EUNKNOWNERR. < < --- > The type of error codes. Errors defined in the POSIX standard and > additional errors from UNIX98 and BSD. All other errors are mapped to > EUNKNOWNERR. 472,477c463,466 < Raised by the system calls below when an error is encountered. < The first component is the error code; the second component is < the function name; the third component is the string parameter < to the function, if it has one, or the empty string otherwise. < < --- > Raised by the system calls below when an error is encountered. The first > component is the error code; the second component is the function name; the > third component is the string parameter to the function, if it has one, or > the empty string otherwise. 485,486d473 < < 491,493c478,480 < handle_unix_error f x applies f to x and returns the result. < If the exception Unix_error is raised, it prints a message < describing the error and exits with code 2. --- > handle_unix_error f x applies f to x and returns the result. If the > exception Unix_error is raised, it prints a message describing the error and > exits with code 2. 500d486 < 505,508c491,492 < Return the process environment, as an array of strings with < the format ``variable=value''. < < --- > Return the process environment, as an array of strings with the format > "variable=value". 514,518c498,500 < Return the value associated to a variable in the process < environment. Raise Not_found if the variable is unbound. (This < function is identical to Sys.getenv.) < < --- > Return the value associated to a variable in the process environment. Raise > Not_found if the variable is unbound. (This function is identical to > Sys.getenv.) 524,526c506,508 < Unix.putenv name value sets the value associated to a variable < in the process environment. name is the name of the environment < variable, and value its new associated value. --- > Unix.putenv name value sets the value associated to a variable in the > process environment. name is the name of the environment variable, and value > its new associated value. 533d514 < 539,540c520 < The process terminated normally by exit; the argument is the < return code. --- > The process terminated normally by exit; the argument is the return code. 546,547c526 < The process was killed by a signal; the argument is the signal < number. --- > The process was killed by a signal; the argument is the signal number. 553,554c532 < The process was stopped by a signal; the argument is the < signal number. --- > The process was stopped by a signal; the argument is the signal number. 558,559d535 < < 565,566c541,542 < do not block if no child has died yet, but immediately return < with a pid equal to 0. --- > do not block if no child has died yet, but immediately return with a pid > equal to 0. 576,577d551 < < 579c553 < val execv : string -> string array -> unit --- > val execv : string -> string array -> 'a 582,585c556,559 < execv prog args execute the program in file prog, with the < arguments args, and the current process environment. < < --- > execv prog args execute the program in file prog, with the arguments args, > and the current process environment. These execv* functions never return: on > success, the current program is replaced by the new one; on failure, a > Unix.Unix_error[21.1] exception is raised. 588c562 < val execve : string -> string array -> string array -> unit --- > val execve : string -> string array -> string array -> 'a 591,594c565,566 < Same as Unix.execv[21.1], except that the third argument < provides the environment to the program executed. < < --- > Same as Unix.execv[21.1], except that the third argument provides the > environment to the program executed. 597c569 < val execvp : string -> string array -> unit --- > val execvp : string -> string array -> 'a 600,603c572 < Same as Unix.execv[21.1] respectively, except that the program < is searched in the path. < < --- > Same as Unix.execv[21.1], except that the program is searched in the path. 606c575 < val execvpe : string -> string array -> string array -> unit --- > val execvpe : string -> string array -> string array -> 'a 609,612c578 < Same as Unix.execvp[21.1] respectively, except that the < program is searched in the path. < < --- > Same as Unix.execve[21.1], except that the program is searched in the path. 618,621c584,585 < Fork a new process. The returned integer is 0 for the child < process, the pid of the child process for the parent process. < < --- > Fork a new process. The returned integer is 0 for the child process, the > pid of the child process for the parent process. 627,630c591,592 < Wait until one of the children processes die, and return its < pid and termination status. < < --- > Wait until one of the children processes die, and return its pid and > termination status. 636,643c598,603 < Same as Unix.wait[21.1], but waits for the process whose pid is < given. A pid of -1 means wait for any child. A pid of 0 means < wait for any child in the same process group as the current < process. Negative pid arguments represent process groups. The < list of options indicates whether waitpid should return < immediately without waiting, or also report stopped children. < < --- > Same as Unix.wait[21.1], but waits for the child process whose pid is > given. A pid of -1 means wait for any child. A pid of 0 means wait for any > child in the same process group as the current process. Negative pid > arguments represent process groups. The list of options indicates whether > waitpid should return immediately without waiting, or also report stopped > children. 649,655c609,612 < Execute the given command, wait until it terminates, and return < its termination status. The string is interpreted by the shell < /bin/sh and therefore can contain redirections, quotes, < variables, etc. The result WEXITED 127 indicates that the shell < couldn't be executed. < < --- > Execute the given command, wait until it terminates, and return its > termination status. The string is interpreted by the shell /bin/sh and > therefore can contain redirections, quotes, variables, etc. The result > WEXITED 127 indicates that the shell couldn't be executed. 663,664d619 < < 671,672d625 < < 677,679c630,632 < Change the process priority. The integer argument is added to < the ``nice'' value. (Higher values of the ``nice'' value mean < lower priorities.) Return the new nice value. --- > Change the process priority. The integer argument is added to the "nice" > value. (Higher values of the "nice" value mean lower priorities.) Return the > new nice value. 686d638 < 693,694d644 < < 701,702d650 < < 709,710d656 < < 715,717c661 < File descriptor for standard standard error. < < --- > File descriptor for standard error. 780d723 < 787d729 < 796,797d737 < < 802,804c742,743 < The type of file access rights. < < --- > The type of file access rights, e.g. 0o640 is read and write for user, read > for group, none for others 807,808c746 < val openfile : < string -> open_flag list -> file_perm -> file_descr --- > val openfile : string -> open_flag list -> file_perm -> file_descr 811,815c749,751 < Open the named file with the given flags. Third argument is < the permissions to give to the file if it is created. Return a < file descriptor on the named file. < < --- > Open the named file with the given flags. Third argument is the permissions > to give to the file if it is created. Return a file descriptor on the named > file. 823,824d758 < < 829,831c763,765 < read fd buff ofs len reads len characters from descriptor fd, < storing them in string buff, starting at position ofs in string < buff. Return the number of characters actually read. --- > read fd buff ofs len reads len characters from descriptor fd, storing them > in string buff, starting at position ofs in string buff. Return the number > of characters actually read. 832a767,769 > << > val write : file_descr -> string -> int -> int -> int > >> 833a771,774 > write fd buff ofs len writes len characters to descriptor fd, taking them > from string buff, starting at position ofs in string buff. Return the number > of characters actually written. write repeats the writing operation until > all characters have been written or an error occurs. 836c777 < val write : file_descr -> string -> int -> int -> int --- > val single_write : file_descr -> string -> int -> int -> int 839,841c780,781 < write fd buff ofs len writes len characters to descriptor fd, < taking them from string buff, starting at position ofs in < string buff. Return the number of characters actually written. --- > Same as write, but attempts to write only once. Thus, if an error occurs, > single_write guarantees that no data has been written. 848d787 < 853,857c792,794 < Create an input channel reading from the given descriptor. The < channel is initially in binary mode; use set_binary_mode_in ic < false if text mode is desired. < < --- > Create an input channel reading from the given descriptor. The channel is > initially in binary mode; use set_binary_mode_in ic false if text mode is > desired. 863,867c800,802 < Create an output channel writing on the given descriptor. The < channel is initially in binary mode; use set_binary_mode_out oc < false if text mode is desired. < < --- > Create an output channel writing on the given descriptor. The channel is > initially in binary mode; use set_binary_mode_out oc false if text mode is > desired. 875,876d809 < < 888d820 < 910,911d841 < < 918,919d847 < < 926,927d853 < < 932,934c858 < Truncates the file corresponding to the given descriptor to < the given size. < --- > Truncates the file corresponding to the given descriptor to the given size. 937,938d860 < File statistics < =============== 939a862,863 > File status > =========== 984d907 < 1064,1065d986 < < 1070,1072c991 < Return the informations for the named file. < < --- > Return the information for the named file. 1078,1079c997,998 < Same as Unix.stat[21.1], but in case the file is a symbolic < link, return the informations for the link itself. --- > Same as Unix.stat[21.1], but in case the file is a symbolic link, return > the information for the link itself. 1080a1000,1002 > << > val fstat : file_descr -> stats > >> 1081a1004 > Return the information for the file associated with the given descriptor. 1084c1007 < val fstat : file_descr -> stats --- > val isatty : file_descr -> bool 1087,1088c1010,1011 < Return the informations for the file associated with the given < descriptor. --- > Return true if the given file descriptor refers to a terminal or console > window, false otherwise. 1096,1098c1019,1136 < module LargeFile : sig end < >> < [21.1.1] --- > module LargeFile : >> > > sig > > > << > val lseek : Unix.file_descr -> int64 -> Unix.seek_command -> int64 > >> > > << > val truncate : string -> int64 -> unit > >> > > << > val ftruncate : Unix.file_descr -> int64 -> unit > >> > > << > type stats = { > st_dev : int ; > >> > > Device number > > << > st_ino : int ; > >> > > Inode number > > << > st_kind : Unix.file_kind ; > >> > > Kind of the file > > << > st_perm : Unix.file_perm ; > >> > > Access rights > > << > st_nlink : int ; > >> > > Number of links > > << > st_uid : int ; > >> > > User id of the owner > > << > st_gid : int ; > >> > > Group ID of the file's group > > << > st_rdev : int ; > >> > > Device minor number > > << > st_size : int64 ; > >> > > Size in bytes > > << > st_atime : float ; > >> > > Last access time > > << > st_mtime : float ; > >> > > Last modification time > > << > st_ctime : float ; > >> > > Last status change time > > << > } > >> > > << > val stat : string -> stats > >> > > << > val lstat : string -> stats > >> > > << > val fstat : Unix.file_descr -> stats > >> > > end > > File operations on large files. This sub-module provides 64-bit variants of > the functions Unix.lseek[21.1] (for positioning a file descriptor), > Unix.truncate[21.1] and Unix.ftruncate[21.1] (for changing the size of a > file), and Unix.stat[21.1], Unix.lstat[21.1] and Unix.fstat[21.1] (for > obtaining information on files). These alternate functions represent > positions and sizes by 64-bit integers (type int64) instead of regular > integers (type int), thus allowing operating on files whose sizes are > greater than max_int. > > 1103d1140 < 1110,1111d1146 < < 1118,1119d1152 < < 1124,1125c1157 < link source dest creates a hard link named dest to the file < named source. --- > link source dest creates a hard link named dest to the file named source. 1132d1163 < 1160,1161d1190 < < 1168,1169d1196 < < 1176,1177d1202 < < 1184,1185d1208 < < 1192,1193d1214 < < 1198,1200c1219 < Set the process creation mask, and return the previous mask. < < --- > Set the process's file mode creation mask, and return the previous mask. 1206,1207c1225,1226 < Check that the process has the given permissions over the named < file. Raise Unix_error otherwise. --- > Check that the process has the given permissions over the named file. Raise > Unix_error otherwise. 1214d1232 < 1219,1222c1237,1238 < Return a new file descriptor referencing the same file as the < given descriptor. < < --- > Return a new file descriptor referencing the same file as the given > descriptor. 1228,1231c1244 < dup2 fd1 fd2 duplicates fd1 to fd2, closing fd2 if already < opened. < < --- > dup2 fd1 fd2 duplicates fd1 to fd2, closing fd2 if already opened. 1237,1244c1250,1254 < Set the ``non-blocking'' flag on the given descriptor. When < the non-blocking flag is set, reading on a descriptor on which < there is temporarily no data available raises the EAGAIN or < EWOULDBLOCK error instead of blocking; writing on a descriptor < on which there is temporarily no room for writing also raises < EAGAIN or EWOULDBLOCK. < < --- > Set the "non-blocking" flag on the given descriptor. When the non-blocking > flag is set, reading on a descriptor on which there is temporarily no data > available raises the EAGAIN or EWOULDBLOCK error instead of blocking; > writing on a descriptor on which there is temporarily no room for writing > also raises EAGAIN or EWOULDBLOCK. 1250c1260 < Clear the ``non-blocking'' flag on the given descriptor. See --- > Clear the "non-blocking" flag on the given descriptor. See 1253,1254d1262 < < 1259,1264c1267,1269 < Set the ``close-on-exec'' flag on the given descriptor. A < descriptor with the close-on-exec flag is automatically closed < when the current process starts another program with one of the < exec functions. < < --- > Set the "close-on-exec" flag on the given descriptor. A descriptor with the > close-on-exec flag is automatically closed when the current process starts > another program with one of the exec functions. 1270c1275 < Clear the ``close-on-exec'' flag on the given descriptor. See --- > Clear the "close-on-exec" flag on the given descriptor. See 1278d1282 < 1285,1286d1288 < < 1293,1294d1294 < < 1301,1302d1300 < < 1309,1310d1306 < < 1317,1318d1312 < < 1325,1326d1318 < < 1333,1334d1324 < < 1340,1343c1330 < Raises End_of_file when the end of the directory has been < reached. < < --- > Raises End_of_file when the end of the directory has been reached. 1351,1352d1337 < < 1364d1348 < 1369,1373c1353,1355 < Create a pipe. The first component of the result is opened for < reading, that's the exit to the pipe. The second component is < opened for writing, that's the entrance to the pipe. < < --- > Create a pipe. The first component of the result is opened for reading, > that's the exit to the pipe. The second component is opened for writing, > that's the entrance to the pipe. 1386d1367 < 1390,1391c1371 < string array -> < file_descr -> file_descr -> file_descr -> int --- > string array -> file_descr -> file_descr -> file_descr -> int 1394,1406c1374,1382 < create_process prog args new_stdin new_stdout new_stderr forks < a new process that executes the program in file prog, with < arguments args. The pid of the new process is returned < immediately; the new process executes concurrently with the < current process. The standard input and outputs of the new < process are connected to the descriptors new_stdin, new_stdout < and new_stderr. Passing e.g. stdout for new_stdout prevents the < redirection and causes the new process to have the same < standard output as the current process. The executable file < prog is searched in the path. The new process has the same < environment as the current process. < < --- > create_process prog args new_stdin new_stdout new_stderr forks a new > process that executes the program in file prog, with arguments args. The pid > of the new process is returned immediately; the new process executes > concurrently with the current process. The standard input and outputs of the > new process are connected to the descriptors new_stdin, new_stdout and > new_stderr. Passing e.g. stdout for new_stdout prevents the redirection and > causes the new process to have the same standard output as the current > process. The executable file prog is searched in the path. The new process > has the same environment as the current process. 1412,1413c1388 < string array -> < file_descr -> file_descr -> file_descr -> int --- > string array -> file_descr -> file_descr -> file_descr -> int 1416,1421c1391,1393 < create_process_env prog args env new_stdin new_stdout < new_stderr works as Unix.create_process[21.1], except that the < extra argument env specifies the environment passed to the < program. < < --- > create_process_env prog args env new_stdin new_stdout new_stderr works as > Unix.create_process[21.1], except that the extra argument env specifies the > environment passed to the program. 1427,1433c1399,1402 < High-level pipe and process management. This function runs the < given command in parallel with the program. The standard output < of the command is redirected to a pipe, which can be read via < the returned input channel. The command is interpreted by the < shell /bin/sh (cf. system). < < --- > High-level pipe and process management. This function runs the given > command in parallel with the program. The standard output of the command is > redirected to a pipe, which can be read via the returned input channel. The > command is interpreted by the shell /bin/sh (cf. system). 1439,1446c1408,1412 < Same as Unix.open_process_in[21.1], but redirect the standard < input of the command to a pipe. Data written to the returned < output channel is sent to the standard input of the command. < Warning: writes on output channels are buffered, hence be < careful to call Pervasives.flush[19.2] at the right times to < ensure correct synchronization. < < --- > Same as Unix.open_process_in[21.1], but redirect the standard input of the > command to a pipe. Data written to the returned output channel is sent to > the standard input of the command. Warning: writes on output channels are > buffered, hence be careful to call Pervasives.flush[19.2] at the right times > to ensure correct synchronization. 1452,1458c1418,1421 < Same as Unix.open_process_out[21.1], but redirects both the < standard input and standard output of the command to pipes < connected to the two returned channels. The input channel is < connected to the output of the command, and the output channel < to the input of the command. < < --- > Same as Unix.open_process_out[21.1], but redirects both the standard input > and standard output of the command to pipes connected to the two returned > channels. The input channel is connected to the output of the command, and > the output channel to the input of the command. 1467,1472c1430,1433 < Similar to Unix.open_process[21.1], but the second argument < specifies the environment passed to the command. The result is < a triple of channels connected respectively to the standard < output, standard input, and standard error of the command. < < --- > Similar to Unix.open_process[21.1], but the second argument specifies the > environment passed to the command. The result is a triple of channels > connected respectively to the standard output, standard input, and standard > error of the command. 1478,1482c1439,1440 < Close channels opened by Unix.open_process_in[21.1], wait for < the associated command to terminate, and return its termination < status. < < --- > Close channels opened by Unix.open_process_in[21.1], wait for the > associated command to terminate, and return its termination status. 1488,1492c1446,1447 < Close channels opened by Unix.open_process_out[21.1], wait < for the associated command to terminate, and return its < termination status. < < --- > Close channels opened by Unix.open_process_out[21.1], wait for the > associated command to terminate, and return its termination status. 1499,1503c1454,1455 < Close channels opened by Unix.open_process[21.1], wait for < the associated command to terminate, and return its termination < status. < < --- > Close channels opened by Unix.open_process[21.1], wait for the associated > command to terminate, and return its termination status. 1511,1513c1463,1464 < Close channels opened by Unix.open_process_full[21.1], wait < for the associated command to terminate, and return its < termination status. --- > Close channels opened by Unix.open_process_full[21.1], wait for the > associated command to terminate, and return its termination status. 1520d1470 < 1525,1528c1475,1476 < symlink source dest creates the file dest as a symbolic link < to the file source. < < --- > symlink source dest creates the file dest as a symbolic link to the file > source. 1541d1488 < 1550,1559c1497,1504 < Wait until some input/output operations become possible on < some channels. The three list arguments are, respectively, a set < of descriptors to check for reading (first argument), for < writing (second argument), or for exceptional conditions (third < argument). The fourth argument is the maximal timeout, in < seconds; a negative fourth argument means no timeout (unbounded < wait). The result is composed of three sets of descriptors: < those ready for reading (first component), ready for writing < (second component), and over which an exceptional condition is < pending (third component). --- > Wait until some input/output operations become possible on some channels. > The three list arguments are, respectively, a set of descriptors to check > for reading (first argument), for writing (second argument), or for > exceptional conditions (third argument). The fourth argument is the maximal > timeout, in seconds; a negative fourth argument means no timeout (unbounded > wait). The result is composed of three sets of descriptors: those ready for > reading (first component), ready for writing (second component), and over > which an exceptional condition is pending (third component). 1566d1510 < 1606,1607d1549 < < 1612,1621c1554,1570 < lockf fd cmd size puts a lock on a region of the file opened < as fd. The region starts at the current read/write position for < fd (as set by Unix.lseek[21.1]), and extends size bytes forward < if size is positive, size bytes backwards if size is negative, < or to the end of the file if size is zero. A write lock (set < with F_LOCK or F_TLOCK) prevents any other process from < acquiring a read or write lock on the region. A read lock (set < with F_RLOCK or F_TRLOCK) prevents any other process from < acquiring a write lock on the region, but lets other processes < acquire read locks on it. --- > lockf fd cmd size puts a lock on a region of the file opened as fd. The > region starts at the current read/write position for fd (as set by > Unix.lseek[21.1]), and extends size bytes forward if size is positive, size > bytes backwards if size is negative, or to the end of the file if size is > zero. A write lock prevents any other process from acquiring a read or write > lock on the region. A read lock prevents any other process from acquiring a > write lock on the region, but lets other processes acquire read locks on it. > The F_LOCK and F_TLOCK commands attempts to put a write lock on the > specified region. The F_RLOCK and F_TRLOCK commands attempts to put a read > lock on the specified region. If one or several locks put by another process > prevent the current process from acquiring the lock, F_LOCK and F_RLOCK > block until these locks are removed, while F_TLOCK and F_TRLOCK fail > immediately with an exception. The F_ULOCK removes whatever locks the > current process has on the specified region. Finally, the F_TEST command > tests whether a write lock can be acquired on the specified region, without > actually putting a lock. It returns immediately if successful, or fails > otherwise. 1630d1578 < 1635,1638c1583 < kill pid sig sends signal number sig to the process with id < pid. < < --- > kill pid sig sends signal number sig to the process with id pid. 1647d1591 < 1652,1659c1596,1600 < sigprocmask cmd sigs changes the set of blocked signals. If < cmd is SIG_SETMASK, blocked signals are set to those in the < list sigs. If cmd is SIG_BLOCK, the signals in sigs are added < to the set of blocked signals. If cmd is SIG_UNBLOCK, the < signals in sigs are removed from the set of blocked signals. < sigprocmask returns the set of previously blocked signals. < < --- > sigprocmask cmd sigs changes the set of blocked signals. If cmd is > SIG_SETMASK, blocked signals are set to those in the list sigs. If cmd is > SIG_BLOCK, the signals in sigs are added to the set of blocked signals. If > cmd is SIG_UNBLOCK, the signals in sigs are removed from the set of blocked > signals. sigprocmask returns the set of previously blocked signals. 1667,1668d1607 < < 1673,1677c1612,1614 < sigsuspend sigs atomically sets the blocked signals to sig and < waits for a non-ignored, non-blocked signal to be delivered. On < return, the blocked signals are reset to their initial value. < < --- > sigsuspend sigs atomically sets the blocked signals to sigs and waits for a > non-ignored, non-blocked signal to be delivered. On return, the blocked > signals are reset to their initial value. 1690d1626 < 1722,1723d1657 < < 1729c1663 < Seconds 0..59 --- > Seconds 0..60 1785,1786d1718 < < 1791,1794c1723 < Return the current time since 00:00:00 GMT, Jan. 1, 1970, in < seconds. < < --- > Return the current time since 00:00:00 GMT, Jan. 1, 1970, in seconds. 1800,1803c1729 < Same as Unix.time[21.1], but with resolution better than 1 < second. < < --- > Same as Unix.time[21.1], but with resolution better than 1 second. 1809,1813c1735,1736 < Convert a time in seconds, as returned by Unix.time[21.1], into < a date and a time. Assumes Greenwich meridian time zone, also < known as UTC. < < --- > Convert a time in seconds, as returned by Unix.time[21.1], into a date and > a time. Assumes UTC (Coordinated Universal Time), also known as GMT. 1819,1822c1742,1743 < Convert a time in seconds, as returned by Unix.time[21.1], into < a date and a time. Assumes the local time zone. < < --- > Convert a time in seconds, as returned by Unix.time[21.1], into a date and > a time. Assumes the local time zone. 1828,1834c1749,1755 < Convert a date and time, specified by the tm argument, into a < time in seconds, as returned by Unix.time[21.1]. Also return a < normalized copy of the given tm record, with the tm_wday, < tm_yday, and tm_isdst fields recomputed from the other fields. < The tm argument is interpreted in the local time zone. < < --- > Convert a date and time, specified by the tm argument, into a time in > seconds, as returned by Unix.time[21.1]. The tm_isdst, tm_wday and tm_yday > fields of tm are ignored. Also return a normalized copy of the given tm > record, with the tm_wday, tm_yday, and tm_isdst fields recomputed from the > other fields, and the other fields normalized (so that, e.g., 40 October is > changed into 9 November). The tm argument is interpreted in the local time > zone. 1842,1843d1762 < < 1850,1851d1768 < < 1858,1859d1774 < < 1864,1868c1779,1781 < Set the last access time (second arg) and last modification < time (third arg) for a file. Times are expressed in seconds < from 00:00:00 GMT, Jan. 1, 1970. < < --- > Set the last access time (second arg) and last modification time (third > arg) for a file. Times are expressed in seconds from 00:00:00 GMT, Jan. 1, > 1970. 1875,1876c1788 < decrements in real time, and sends the signal SIGALRM when < expired. --- > decrements in real time, and sends the signal SIGALRM when expired. 1882,1883c1794 < decrements in process virtual time, and sends SIGVTALRM when < expired. --- > decrements in process virtual time, and sends SIGVTALRM when expired. 1889,1891c1800,1801 < (for profiling) decrements both when the process is running < and when the system is running on behalf of the process; it < sends SIGPROF when expired. --- > (for profiling) decrements both when the process is running and when the > system is running on behalf of the process; it sends SIGPROF when expired. 1895,1896d1804 < < 1916,1917d1823 < < 1924,1925d1829 < < 1932,1938c1836,1841 < setitimer t s sets the interval timer t and returns its < previous status. The s argument is interpreted as follows: < s.it_value, if nonzero, is the time to the next timer < expiration; s.it_interval, if nonzero, specifies a value to be < used in reloading it_value when the timer expires. Setting < s.it_value to zero disable the timer. Setting s.it_interval to < zero causes the timer to be disabled after its next expiration. --- > setitimer t s sets the interval timer t and returns its previous status. > The s argument is interpreted as follows: s.it_value, if nonzero, is the > time to the next timer expiration; s.it_interval, if nonzero, specifies a > value to be used in reloading it_value when the timer expires. Setting > s.it_value to zero disable the timer. Setting s.it_interval to zero causes > the timer to be disabled after its next expiration. 1945d1847 < 1952,1953d1853 < < 1960,1961d1859 < < 1968,1969d1865 < < 1976,1977d1871 < < 1984,1985d1877 < < 1992,1993d1883 < < 1998,2001c1888 < Return the list of groups to which the user executing the < process belongs. < < --- > Return the list of groups to which the user executing the process belongs. 2017,2018d1903 < < 2030,2031d1914 < < 2038,2039d1920 < < 2044,2047c1925 < Find an entry in passwd with the given name, or raise < Not_found. < < --- > Find an entry in passwd with the given name, or raise Not_found. 2053,2056c1931 < Find an entry in group with the given name, or raise < Not_found. < < --- > Find an entry in group with the given name, or raise Not_found. 2062,2065c1937 < Find an entry in passwd with the given user id, or raise < Not_found. < < --- > Find an entry in passwd with the given user id, or raise Not_found. 2071,2072c1943 < Find an entry in group with the given group id, or raise < Not_found. --- > Find an entry in group with the given group id, or raise Not_found. 2079d1949 < 2085a1956,1958 > << > val inet_addr_of_string : string -> inet_addr > >> 2086a1960,1964 > Conversion from the printable representation of an Internet address to its > internal representation. The argument string consists of 4 numbers separated > by periods (XXX.YYY.ZZZ.TTT) for IPv4 addresses, and up to 8 numbers > separated by colons for IPv6 addresses. Raise Failure when given a string > that does not match these formats. 2089c1967 < val inet_addr_of_string : string -> inet_addr --- > val string_of_inet_addr : inet_addr -> string 2092,2094c1970,1972 < Conversions between string with the format XXX.YYY.ZZZ.TTT and < Internet addresses. inet_addr_of_string raises Failure when < given a string that does not match this format. --- > Return the printable representation of the given Internet address. See > Unix.inet_addr_of_string[21.1] for a description of the printable > representation. 2095a1974,1976 > << > val inet_addr_any : inet_addr > >> 2096a1978,1979 > A special IPv4 address, for use only with bind, representing all the > Internet addresses that the host machine possesses. 2099c1982 < val string_of_inet_addr : inet_addr -> string --- > val inet_addr_loopback : inet_addr 2102c1985 < See Unix.inet_addr_of_string[21.1]. --- > A special IPv4 address representing the host machine (127.0.0.1). 2103a1987,1989 > << > val inet6_addr_any : inet_addr > >> 2104a1991,1992 > A special IPv6 address, for use only with bind, representing all the > Internet addresses that the host machine possesses. 2107c1995 < val inet_addr_any : inet_addr --- > val inet6_addr_loopback : inet_addr 2110,2112c1998 < A special Internet address, for use only with bind, < representing all the Internet addresses that the host machine < possesses. --- > A special IPv6 address representing the host machine (::1). 2119d2004 < 2131c2016 < Internet domain --- > Internet domain (IPv4) 2133c2018,2020 < The type of socket domains. --- > << > | PF_INET6 > >> 2134a2022 > Internet domain (IPv6) 2135a2024 > The type of socket domains. 2162,2165c2051 < The type of socket kinds, specifying the semantics of < communications. < < --- > The type of socket kinds, specifying the semantics of communications. 2173,2178c2059,2062 < The type of socket addresses. ADDR_UNIX name is a socket < address in the Unix domain; name is a file name in the file < system. ADDR_INET(addr,port) is a socket address in the Internet < domain; addr is the Internet address of the machine, and port < is the port number. < --- > The type of socket addresses. ADDR_UNIX name is a socket address in the > Unix domain; name is a file name in the file system. ADDR_INET(addr,port) is > a socket address in the Internet domain; addr is the Internet address of the > machine, and port is the port number. 2184,2186c2068,2070 < Create a new socket in the given domain, and with the given < kind. The third argument is the protocol type; 0 selects the < default protocol for that kind of sockets. --- > Create a new socket in the given domain, and with the given kind. The third > argument is the protocol type; 0 selects the default protocol for that kind > of sockets. 2187a2072,2074 > << > val domain_of_sockaddr : sockaddr -> socket_domain > >> 2188a2076 > Return the socket domain adequate for the given socket address. 2198,2199d2085 < < 2204,2208c2090,2092 < Accept connections on the given socket. The returned descriptor < is a socket connected to the client; the returned address is < the address of the connecting client. < < --- > Accept connections on the given socket. The returned descriptor is a socket > connected to the client; the returned address is the address of the > connecting client. 2216,2217d2099 < < 2224,2225d2105 < < 2230,2233c2110,2111 < Set up a socket for receiving connection requests. The integer < argument is the maximal number of pending requests. < < --- > Set up a socket for receiving connection requests. The integer argument is > the maximal number of pending requests. 2256,2257d2133 < < 2262,2268c2138,2141 < Shutdown a socket connection. SHUTDOWN_SEND as second argument < causes reads on the other end of the connection to return an < end-of-file condition. SHUTDOWN_RECEIVE causes writes on the < other end of the connection to return a closed pipe condition < (SIGPIPE signal). < < --- > Shutdown a socket connection. SHUTDOWN_SEND as second argument causes reads > on the other end of the connection to return an end-of-file condition. > SHUTDOWN_RECEIVE causes writes on the other end of the connection to return > a closed pipe condition (SIGPIPE signal). 2276,2277d2148 < < 2284,2285d2154 < < 2293,2295c2162,2163 < The flags for Unix.recv[21.1], Unix.recvfrom[21.1], < Unix.send[21.1] and Unix.sendto[21.1]. < --- > The flags for Unix.recv[21.1], Unix.recvfrom[21.1], Unix.send[21.1] and > Unix.sendto[21.1]. 2298,2299c2166 < val recv : < file_descr -> string -> int -> int -> msg_flag list -> int --- > val recv : file_descr -> string -> int -> int -> msg_flag list -> int 2304,2305d2170 < < 2314,2315d2178 < < 2317,2318c2180 < val send : < file_descr -> string -> int -> int -> msg_flag list -> int --- > val send : file_descr -> string -> int -> int -> msg_flag list -> int 2323,2324d2184 < < 2338d2197 < 2382,2386c2241,2243 < The socket options that can be consulted with < Unix.getsockopt[21.1] and modified with Unix.setsockopt[21.1]. < These options have a boolean (true/false) value. < < --- > The socket options that can be consulted with Unix.getsockopt[21.1] and > modified with Unix.setsockopt[21.1]. These options have a boolean > (true/false) value. 2425,2429c2282,2284 < The socket options that can be consulted with < Unix.getsockopt_int[21.1] and modified with < Unix.setsockopt_int[21.1]. These options have an integer value. < < --- > The socket options that can be consulted with Unix.getsockopt_int[21.1] and > modified with Unix.setsockopt_int[21.1]. These options have an integer > value. 2436,2443c2291,2292 < Whether to linger on closed connections that have data < present, and for how long (in seconds) < < The socket options that can be consulted with < Unix.getsockopt_optint[21.1] and modified with < Unix.setsockopt_optint[21.1]. These options have a value of < type int option, with None meaning ``disabled''. < --- > Whether to linger on closed connections that have data present, and for how > long (in seconds) 2444a2294,2296 > The socket options that can be consulted with Unix.getsockopt_optint[21.1] > and modified with Unix.setsockopt_optint[21.1]. These options have a value > of type int option, with None meaning "disabled". 2459,2465c2311,2314 < The socket options that can be consulted with < Unix.getsockopt_float[21.1] and modified with < Unix.setsockopt_float[21.1]. These options have a < floating-point value representing a time in seconds. The value < 0 means infinite timeout. < < --- > The socket options that can be consulted with Unix.getsockopt_float[21.1] > and modified with Unix.setsockopt_float[21.1]. These options have a > floating-point value representing a time in seconds. The value 0 means > infinite timeout. 2471,2474c2320 < Return the current status of a boolean-valued option in the < given socket. < < --- > Return the current status of a boolean-valued option in the given socket. 2482,2483d2327 < < 2488,2491c2332 < Same as Unix.getsockopt[21.1] for an integer-valued socket < option. < < --- > Same as Unix.getsockopt[21.1] for an integer-valued socket option. 2497,2500c2338 < Same as Unix.setsockopt[21.1] for an integer-valued socket < option. < < --- > Same as Unix.setsockopt[21.1] for an integer-valued socket option. 2503,2504c2341 < val getsockopt_optint : < file_descr -> socket_optint_option -> int option --- > val getsockopt_optint : file_descr -> socket_optint_option -> int option 2507,2510c2344,2345 < Same as Unix.getsockopt[21.1] for a socket option whose value < is an int option. < < --- > Same as Unix.getsockopt[21.1] for a socket option whose value is an int > option. 2517,2520c2352,2353 < Same as Unix.setsockopt[21.1] for a socket option whose value < is an int option. < < --- > Same as Unix.setsockopt[21.1] for a socket option whose value is an int > option. 2526,2529c2359,2360 < Same as Unix.getsockopt[21.1] for a socket option whose value < is a floating-point number. < < --- > Same as Unix.getsockopt[21.1] for a socket option whose value is a > floating-point number. 2532,2533c2363 < val setsockopt_float : < file_descr -> socket_float_option -> float -> unit --- > val setsockopt_float : file_descr -> socket_float_option -> float -> unit 2536,2537c2366,2367 < Same as Unix.setsockopt[21.1] for a socket option whose value < is a floating-point number. --- > Same as Unix.setsockopt[21.1] for a socket option whose value is a > floating-point number. 2544d2373 < 2550,2555c2379,2381 < Connect to a server at the given address. Return a pair of < buffered channels connected to the server. Remember to call < Pervasives.flush[19.2] on the output channel at the right times < to ensure correct synchronization. < < --- > Connect to a server at the given address. Return a pair of buffered > channels connected to the server. Remember to call Pervasives.flush[19.2] on > the output channel at the right times to ensure correct synchronization. 2561,2566c2387,2389 < ``Shut down'' a connection established with < Unix.open_connection[21.1]; that is, transmit an end-of-file < condition to the server reading on the other side of the < connection. < < --- > "Shut down" a connection established with Unix.open_connection[21.1]; that > is, transmit an end-of-file condition to the server reading on the other > side of the connection. 2574,2578c2397,2400 < Establish a server on the given address. The function given as < first argument is called for each connection with two buffered < channels connected to the client. A new process is created for < each connection. The function Unix.establish_server[21.1] never < returns normally. --- > Establish a server on the given address. The function given as first > argument is called for each connection with two buffered channels connected > to the client. A new process is created for each connection. The function > Unix.establish_server[21.1] never returns normally. 2585d2406 < 2597,2598d2417 < < 2609,2610d2427 < < 2622,2623d2438 < < 2629a2445,2447 > << > val gethostbyname : string -> host_entry > >> 2630a2449 > Find an entry in hosts with the given name, or raise Not_found. 2633c2452 < val gethostbyname : string -> host_entry --- > val gethostbyaddr : inet_addr -> host_entry 2636,2637c2455 < Find an entry in hosts with the given name, or raise < Not_found. --- > Find an entry in hosts with the given address, or raise Not_found. 2638a2457,2459 > << > val getprotobyname : string -> protocol_entry > >> 2639a2461 > Find an entry in protocols with the given name, or raise Not_found. 2642c2464 < val gethostbyaddr : inet_addr -> host_entry --- > val getprotobynumber : int -> protocol_entry 2645c2467 < Find an entry in hosts with the given address, or raise --- > Find an entry in protocols with the given protocol number, or raise 2647a2470,2472 > << > val getservbyname : string -> string -> service_entry > >> 2648a2474 > Find an entry in services with the given name, or raise Not_found. 2651c2477 < val getprotobyname : string -> protocol_entry --- > val getservbyport : int -> string -> service_entry 2654c2480 < Find an entry in protocols with the given name, or raise --- > Find an entry in services with the given service number, or raise 2656a2483,2486 > << > type addr_info = { > ai_family : socket_domain ; > >> 2657a2488 > Socket domain 2660c2491 < val getprotobynumber : int -> protocol_entry --- > ai_socktype : socket_type ; 2663,2664c2494 < Find an entry in protocols with the given protocol number, or < raise Not_found. --- > Socket type 2665a2496,2498 > << > ai_protocol : int ; > >> 2666a2500 > Socket protocol number 2669c2503 < val getservbyname : string -> string -> service_entry --- > ai_addr : sockaddr ; 2672,2673c2506,2518 < Find an entry in services with the given name, or raise < Not_found. --- > Address > > << > ai_canonname : string ; > >> > > Canonical host name > > << > } > >> > > Address information returned by Unix.getaddrinfo[21.1]. 2674a2520,2523 > << > type getaddrinfo_option = > | AI_FAMILY of socket_domain > >> 2675a2525 > Impose the given socket domain 2678c2528,2540 < val getservbyport : int -> string -> service_entry --- > | AI_SOCKTYPE of socket_type > >> > > Impose the given socket type > > << > | AI_PROTOCOL of int > >> > > Impose the given protocol > > << > | AI_NUMERICHOST 2681,2682c2543,2633 < Find an entry in services with the given service number, or < raise Not_found. --- > Do not call name resolver, expect numeric IP address > > << > | AI_CANONNAME > >> > > Fill the ai_canonname field of the result > > << > | AI_PASSIVE > >> > > Set address to "any" address for use with Unix.bind[21.1] > > Options to Unix.getaddrinfo[21.1]. > > << > val getaddrinfo : > string -> string -> getaddrinfo_option list -> addr_info list > >> > > getaddrinfo host service opts returns a list of Unix.addr_info[21.1] > records describing socket parameters and addresses suitable for > communicating with the given host and service. The empty list is returned if > the host or service names are unknown, or the constraints expressed in opts > cannot be satisfied. > host is either a host name or the string representation of an IP address. > host can be given as the empty string; in this case, the "any" address or > the "loopback" address are used, depending whether opts contains AI_PASSIVE. > service is either a service name or the string representation of a port > number. service can be given as the empty string; in this case, the port > field of the returned addresses is set to 0. opts is a possibly empty list > of options that allows the caller to force a particular socket domain (e.g. > IPv6 only or IPv4 only) or a particular socket type (e.g. TCP only or UDP > only). > > << > type name_info = { > ni_hostname : string ; > >> > > Name or IP address of host > > << > ni_service : string ; > } > >> > > Name of service or port number > > Host and service information returned by Unix.getnameinfo[21.1]. > << > type getnameinfo_option = > | NI_NOFQDN > >> > > Do not qualify local host names > > << > | NI_NUMERICHOST > >> > > Always return host as IP address > > << > | NI_NAMEREQD > >> > > Fail if host name cannot be determined > > << > | NI_NUMERICSERV > >> > > Always return service as port number > > << > | NI_DGRAM > >> > > Consider the service as UDP-based instead of the default TCP > > Options to Unix.getnameinfo[21.1]. > > << > val getnameinfo : sockaddr -> getnameinfo_option list -> name_info > >> > > getnameinfo addr opts returns the host name and service name corresponding > to the socket address addr. opts is a possibly empty list of options that > governs how these names are obtained. Raise Not_found if an error occurs. 2689,2692c2640,2642 < The following functions implement the POSIX standard terminal interface. < They provide control over asynchronous communication ports and < pseudo-terminals. Refer to the termios man page for a complete description. < --- > The following functions implement the POSIX standard terminal interface. They > provide control over asynchronous communication ports and pseudo-terminals. > Refer to the termios man page for a complete description. 2902,2903c2852 < Minimum number of characters to read before the read request < is satisfied. --- > Minimum number of characters to read before the read request is satisfied. 2927d2875 < 2932,2935c2880 < Return the status of the terminal referred to by the given < file descriptor. < < --- > Return the status of the terminal referred to by the given file descriptor. 2944d2888 < 2946,2947c2890 < val tcsetattr : < file_descr -> setattr_when -> terminal_io -> unit --- > val tcsetattr : file_descr -> setattr_when -> terminal_io -> unit 2950,2955c2893,2897 < Set the status of the terminal referred to by the given file < descriptor. The second argument indicates when the status < change takes place: immediately (TCSANOW), when all pending < output has been transmitted (TCSADRAIN), or after flushing all < input that has been received but not read (TCSAFLUSH). < TCSADRAIN is recommended when changing the output parameters; --- > Set the status of the terminal referred to by the given file descriptor. > The second argument indicates when the status change takes place: > immediately (TCSANOW), when all pending output has been transmitted > (TCSADRAIN), or after flushing all input that has been received but not read > (TCSAFLUSH). TCSADRAIN is recommended when changing the output parameters; 2958,2959d2899 < < 2964,2968c2904,2905 < Send a break condition on the given file descriptor. The < second argument is the duration of the break, in 0.1s units; 0 < means standard duration (0.25s). < < --- > Send a break condition on the given file descriptor. The second argument is > the duration of the break, in 0.1s units; 0 means standard duration (0.25s). 2974,2977c2911,2912 < Waits until all output written on the given file descriptor < has been transmitted. < < --- > Waits until all output written on the given file descriptor has been > transmitted. 2986d2920 < 2991,2997c2925,2928 < Discard data written on the given file descriptor but not yet < transmitted, or data received but not yet read, depending on the < second argument: TCIFLUSH flushes data received but not read, < TCOFLUSH flushes data written but not transmitted, and < TCIOFLUSH flushes both. < < --- > Discard data written on the given file descriptor but not yet transmitted, > or data received but not yet read, depending on the second argument: > TCIFLUSH flushes data received but not read, TCOFLUSH flushes data written > but not transmitted, and TCIOFLUSH flushes both. 3007d2937 < 3012,3018c2942,2945 < Suspend or restart reception or transmission of data on the < given file descriptor, depending on the second argument: TCOOFF < suspends output, TCOON restarts output, TCIOFF transmits a STOP < character to suspend input, and TCION transmits a START < character to restart input. < < --- > Suspend or restart reception or transmission of data on the given file > descriptor, depending on the second argument: TCOOFF suspends output, TCOON > restarts output, TCIOFF transmits a STOP character to suspend input, and > TCION transmits a START character to restart input. 3024,3157c2951,2952 < Put the calling process in a new session and detach it from < its controlling terminal. < < < < < 21.1.1 Module Unix.LargeFile : File operations on large files. < =============================================================== < < << < module LargeFile : sig < >> < < < This sub-module provides 64-bit variants of the functions Unix.lseek[21.1] < (for positioning a file descriptor), Unix.truncate[21.1] and < Unix.ftruncate[21.1] (for changing the size of a file), and Unix.stat[21.1], < Unix.lstat[21.1] and Unix.fstat[21.1] (for obtaining information on files). < These alternate functions represent positions and sizes by 64-bit integers < (type int64) instead of regular integers (type int), thus allowing operating < on files whose sizes are greater than max_int. < < < < << < val lseek : Unix.file_descr -> int64 -> Unix.seek_command -> int64 < >> < < < << < val truncate : string -> int64 -> unit < >> < < < << < val ftruncate : Unix.file_descr -> int64 -> unit < >> < < < << < type stats = { < st_dev : int ; < >> < < Device number < < << < st_ino : int ; < >> < < Inode number < < << < st_kind : Unix.file_kind ; < >> < < Kind of the file < < << < st_perm : Unix.file_perm ; < >> < < Access rights < < << < st_nlink : int ; < >> < < Number of links < < << < st_uid : int ; < >> < < User id of the owner < < << < st_gid : int ; < >> < < Group ID of the file's group < < << < st_rdev : int ; < >> < < Device minor number < < << < st_size : int64 ; < >> < < Size in bytes < < << < st_atime : float ; < >> < < Last access time < < << < st_mtime : float ; < >> < < Last modification time < < << < st_ctime : float ; < >> < < Last status change time < < << < } < >> < < < << < val stat : string -> stats < >> < < < << < val lstat : string -> stats < >> < < < << < val fstat : Unix.file_descr -> stats < >> < < << < end < >> --- > Put the calling process in a new session and detach it from its controlling > terminal. 3168,3207d2962 < 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 | < ---------------------------------------------------------- < 3209,3214c2964,2968 < 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. --- > The Cygwin port of Objective Caml fully implements all functions from the > Unix module. The native Win32 ports implement a subset of them. Below is a > list of the functions that are not implemented, or only partially > implemented, by the Win32 ports. Functions not mentioned are fully > implemented and behave as described previously in this chapter. 3219c2973 < |fork |not implemented, use | --- > | fork |not implemented, use | 3234c2988 < | |under NT and 2000 | --- > | |under NT, 2000, XP | 3255c3009 < | |threads if you need to| --- > | |threads if you need to | 3271a3026,3029 > |open_connection |does not work under | > | |Windows 95, 98, ME; | > | |works fine under NT, | > | |2000, XP | |