/otherlibs/unix/unix.mli

http://github.com/multani/ocaml-mirror · OCaml · 1337 lines · 503 code · 282 blank · 552 comment · 0 complexity · 6974efaa74f941dceae08defed68f53a MD5 · raw file

Large files are truncated click here to view the full file

  1. (***********************************************************************)
  2. (* *)
  3. (* OCaml *)
  4. (* *)
  5. (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
  6. (* *)
  7. (* Copyright 1996 Institut National de Recherche en Informatique et *)
  8. (* en Automatique. All rights reserved. This file is distributed *)
  9. (* under the terms of the GNU Library General Public License, with *)
  10. (* the special exception on linking described in file ../../LICENSE. *)
  11. (* *)
  12. (***********************************************************************)
  13. (* $Id$ *)
  14. (** Interface to the Unix system *)
  15. (** {6 Error report} *)
  16. type error =
  17. E2BIG (** Argument list too long *)
  18. | EACCES (** Permission denied *)
  19. | EAGAIN (** Resource temporarily unavailable; try again *)
  20. | EBADF (** Bad file descriptor *)
  21. | EBUSY (** Resource unavailable *)
  22. | ECHILD (** No child process *)
  23. | EDEADLK (** Resource deadlock would occur *)
  24. | EDOM (** Domain error for math functions, etc. *)
  25. | EEXIST (** File exists *)
  26. | EFAULT (** Bad address *)
  27. | EFBIG (** File too large *)
  28. | EINTR (** Function interrupted by signal *)
  29. | EINVAL (** Invalid argument *)
  30. | EIO (** Hardware I/O error *)
  31. | EISDIR (** Is a directory *)
  32. | EMFILE (** Too many open files by the process *)
  33. | EMLINK (** Too many links *)
  34. | ENAMETOOLONG (** Filename too long *)
  35. | ENFILE (** Too many open files in the system *)
  36. | ENODEV (** No such device *)
  37. | ENOENT (** No such file or directory *)
  38. | ENOEXEC (** Not an executable file *)
  39. | ENOLCK (** No locks available *)
  40. | ENOMEM (** Not enough memory *)
  41. | ENOSPC (** No space left on device *)
  42. | ENOSYS (** Function not supported *)
  43. | ENOTDIR (** Not a directory *)
  44. | ENOTEMPTY (** Directory not empty *)
  45. | ENOTTY (** Inappropriate I/O control operation *)
  46. | ENXIO (** No such device or address *)
  47. | EPERM (** Operation not permitted *)
  48. | EPIPE (** Broken pipe *)
  49. | ERANGE (** Result too large *)
  50. | EROFS (** Read-only file system *)
  51. | ESPIPE (** Invalid seek e.g. on a pipe *)
  52. | ESRCH (** No such process *)
  53. | EXDEV (** Invalid link *)
  54. | EWOULDBLOCK (** Operation would block *)
  55. | EINPROGRESS (** Operation now in progress *)
  56. | EALREADY (** Operation already in progress *)
  57. | ENOTSOCK (** Socket operation on non-socket *)
  58. | EDESTADDRREQ (** Destination address required *)
  59. | EMSGSIZE (** Message too long *)
  60. | EPROTOTYPE (** Protocol wrong type for socket *)
  61. | ENOPROTOOPT (** Protocol not available *)
  62. | EPROTONOSUPPORT (** Protocol not supported *)
  63. | ESOCKTNOSUPPORT (** Socket type not supported *)
  64. | EOPNOTSUPP (** Operation not supported on socket *)
  65. | EPFNOSUPPORT (** Protocol family not supported *)
  66. | EAFNOSUPPORT (** Address family not supported by protocol family *)
  67. | EADDRINUSE (** Address already in use *)
  68. | EADDRNOTAVAIL (** Can't assign requested address *)
  69. | ENETDOWN (** Network is down *)
  70. | ENETUNREACH (** Network is unreachable *)
  71. | ENETRESET (** Network dropped connection on reset *)
  72. | ECONNABORTED (** Software caused connection abort *)
  73. | ECONNRESET (** Connection reset by peer *)
  74. | ENOBUFS (** No buffer space available *)
  75. | EISCONN (** Socket is already connected *)
  76. | ENOTCONN (** Socket is not connected *)
  77. | ESHUTDOWN (** Can't send after socket shutdown *)
  78. | ETOOMANYREFS (** Too many references: can't splice *)
  79. | ETIMEDOUT (** Connection timed out *)
  80. | ECONNREFUSED (** Connection refused *)
  81. | EHOSTDOWN (** Host is down *)
  82. | EHOSTUNREACH (** No route to host *)
  83. | ELOOP (** Too many levels of symbolic links *)
  84. | EOVERFLOW (** File size or position not representable *)
  85. | EUNKNOWNERR of int (** Unknown error *)
  86. (** The type of error codes.
  87. Errors defined in the POSIX standard
  88. and additional errors from UNIX98 and BSD.
  89. All other errors are mapped to EUNKNOWNERR.
  90. *)
  91. exception Unix_error of error * string * string
  92. (** Raised by the system calls below when an error is encountered.
  93. The first component is the error code; the second component
  94. is the function name; the third component is the string parameter
  95. to the function, if it has one, or the empty string otherwise. *)
  96. val error_message : error -> string
  97. (** Return a string describing the given error code. *)
  98. val handle_unix_error : ('a -> 'b) -> 'a -> 'b
  99. (** [handle_unix_error f x] applies [f] to [x] and returns the result.
  100. If the exception [Unix_error] is raised, it prints a message
  101. describing the error and exits with code 2. *)
  102. (** {6 Access to the process environment} *)
  103. val environment : unit -> string array
  104. (** Return the process environment, as an array of strings
  105. with the format ``variable=value''. *)
  106. val getenv : string -> string
  107. (** Return the value associated to a variable in the process
  108. environment. Raise [Not_found] if the variable is unbound.
  109. (This function is identical to [Sys.getenv].) *)
  110. val putenv : string -> string -> unit
  111. (** [Unix.putenv name value] sets the value associated to a
  112. variable in the process environment.
  113. [name] is the name of the environment variable,
  114. and [value] its new associated value. *)
  115. (** {6 Process handling} *)
  116. type process_status =
  117. WEXITED of int
  118. (** The process terminated normally by [exit];
  119. the argument is the return code. *)
  120. | WSIGNALED of int
  121. (** The process was killed by a signal;
  122. the argument is the signal number. *)
  123. | WSTOPPED of int
  124. (** The process was stopped by a signal; the argument is the
  125. signal number. *)
  126. (** The termination status of a process. See module {!Sys} for the
  127. definitions of the standard signal numbers. Note that they are
  128. not the numbers used by the OS. *)
  129. type wait_flag =
  130. WNOHANG (** do not block if no child has
  131. died yet, but immediately return with a pid equal to 0.*)
  132. | WUNTRACED (** report also the children that receive stop signals. *)
  133. (** Flags for {!Unix.waitpid}. *)
  134. val execv : string -> string array -> 'a
  135. (** [execv prog args] execute the program in file [prog], with
  136. the arguments [args], and the current process environment.
  137. These [execv*] functions never return: on success, the current
  138. program is replaced by the new one;
  139. on failure, a {!Unix.Unix_error} exception is raised. *)
  140. val execve : string -> string array -> string array -> 'a
  141. (** Same as {!Unix.execv}, except that the third argument provides the
  142. environment to the program executed. *)
  143. val execvp : string -> string array -> 'a
  144. (** Same as {!Unix.execv}, except that
  145. the program is searched in the path. *)
  146. val execvpe : string -> string array -> string array -> 'a
  147. (** Same as {!Unix.execve}, except that
  148. the program is searched in the path. *)
  149. val fork : unit -> int
  150. (** Fork a new process. The returned integer is 0 for the child
  151. process, the pid of the child process for the parent process. *)
  152. val wait : unit -> int * process_status
  153. (** Wait until one of the children processes die, and return its pid
  154. and termination status. *)
  155. val waitpid : wait_flag list -> int -> int * process_status
  156. (** Same as {!Unix.wait}, but waits for the child process whose pid is given.
  157. A pid of [-1] means wait for any child.
  158. A pid of [0] means wait for any child in the same process group
  159. as the current process.
  160. Negative pid arguments represent process groups.
  161. The list of options indicates whether [waitpid] should return
  162. immediately without waiting, or also report stopped children. *)
  163. val system : string -> process_status
  164. (** Execute the given command, wait until it terminates, and return
  165. its termination status. The string is interpreted by the shell
  166. [/bin/sh] and therefore can contain redirections, quotes, variables,
  167. etc. The result [WEXITED 127] indicates that the shell couldn't
  168. be executed. *)
  169. val getpid : unit -> int
  170. (** Return the pid of the process. *)
  171. val getppid : unit -> int
  172. (** Return the pid of the parent process. *)
  173. val nice : int -> int
  174. (** Change the process priority. The integer argument is added to the
  175. ``nice'' value. (Higher values of the ``nice'' value mean
  176. lower priorities.) Return the new nice value. *)
  177. (** {6 Basic file input/output} *)
  178. type file_descr
  179. (** The abstract type of file descriptors. *)
  180. val stdin : file_descr
  181. (** File descriptor for standard input.*)
  182. val stdout : file_descr
  183. (** File descriptor for standard output.*)
  184. val stderr : file_descr
  185. (** File descriptor for standard error. *)
  186. type open_flag =
  187. O_RDONLY (** Open for reading *)
  188. | O_WRONLY (** Open for writing *)
  189. | O_RDWR (** Open for reading and writing *)
  190. | O_NONBLOCK (** Open in non-blocking mode *)
  191. | O_APPEND (** Open for append *)
  192. | O_CREAT (** Create if nonexistent *)
  193. | O_TRUNC (** Truncate to 0 length if existing *)
  194. | O_EXCL (** Fail if existing *)
  195. | O_NOCTTY (** Don't make this dev a controlling tty *)
  196. | O_DSYNC (** Writes complete as `Synchronised I/O data
  197. integrity completion' *)
  198. | O_SYNC (** Writes complete as `Synchronised I/O file
  199. integrity completion' *)
  200. | O_RSYNC (** Reads complete as writes (depending on
  201. O_SYNC/O_DSYNC) *)
  202. | O_SHARE_DELETE (** Windows only: allow the file to be deleted
  203. while still open *)
  204. (** The flags to {!Unix.openfile}. *)
  205. type file_perm = int
  206. (** The type of file access rights, e.g. [0o640] is read and write for user,
  207. read for group, none for others *)
  208. val openfile : string -> open_flag list -> file_perm -> file_descr
  209. (** Open the named file with the given flags. Third argument is
  210. the permissions to give to the file if it is created. Return
  211. a file descriptor on the named file. *)
  212. val close : file_descr -> unit
  213. (** Close a file descriptor. *)
  214. val read : file_descr -> string -> int -> int -> int
  215. (** [read fd buff ofs len] reads [len] characters from descriptor
  216. [fd], storing them in string [buff], starting at position [ofs]
  217. in string [buff]. Return the number of characters actually read. *)
  218. val write : file_descr -> string -> int -> int -> int
  219. (** [write fd buff ofs len] writes [len] characters to descriptor
  220. [fd], taking them from string [buff], starting at position [ofs]
  221. in string [buff]. Return the number of characters actually
  222. written. [write] repeats the writing operation until all characters
  223. have been written or an error occurs. *)
  224. val single_write : file_descr -> string -> int -> int -> int
  225. (** Same as [write], but attempts to write only once.
  226. Thus, if an error occurs, [single_write] guarantees that no data
  227. has been written. *)
  228. (** {6 Interfacing with the standard input/output library} *)
  229. val in_channel_of_descr : file_descr -> in_channel
  230. (** Create an input channel reading from the given descriptor.
  231. The channel is initially in binary mode; use
  232. [set_binary_mode_in ic false] if text mode is desired. *)
  233. val out_channel_of_descr : file_descr -> out_channel
  234. (** Create an output channel writing on the given descriptor.
  235. The channel is initially in binary mode; use
  236. [set_binary_mode_out oc false] if text mode is desired. *)
  237. val descr_of_in_channel : in_channel -> file_descr
  238. (** Return the descriptor corresponding to an input channel. *)
  239. val descr_of_out_channel : out_channel -> file_descr
  240. (** Return the descriptor corresponding to an output channel. *)
  241. (** {6 Seeking and truncating} *)
  242. type seek_command =
  243. SEEK_SET (** indicates positions relative to the beginning of the file *)
  244. | SEEK_CUR (** indicates positions relative to the current position *)
  245. | SEEK_END (** indicates positions relative to the end of the file *)
  246. (** Positioning modes for {!Unix.lseek}. *)
  247. val lseek : file_descr -> int -> seek_command -> int
  248. (** Set the current position for a file descriptor *)
  249. val truncate : string -> int -> unit
  250. (** Truncates the named file to the given size. *)
  251. val ftruncate : file_descr -> int -> unit
  252. (** Truncates the file corresponding to the given descriptor
  253. to the given size. *)
  254. (** {6 File status} *)
  255. type file_kind =
  256. S_REG (** Regular file *)
  257. | S_DIR (** Directory *)
  258. | S_CHR (** Character device *)
  259. | S_BLK (** Block device *)
  260. | S_LNK (** Symbolic link *)
  261. | S_FIFO (** Named pipe *)
  262. | S_SOCK (** Socket *)
  263. type stats =
  264. { st_dev : int; (** Device number *)
  265. st_ino : int; (** Inode number *)
  266. st_kind : file_kind; (** Kind of the file *)
  267. st_perm : file_perm; (** Access rights *)
  268. st_nlink : int; (** Number of links *)
  269. st_uid : int; (** User id of the owner *)
  270. st_gid : int; (** Group ID of the file's group *)
  271. st_rdev : int; (** Device minor number *)
  272. st_size : int; (** Size in bytes *)
  273. st_atime : float; (** Last access time *)
  274. st_mtime : float; (** Last modification time *)
  275. st_ctime : float; (** Last status change time *)
  276. }
  277. (** The information returned by the {!Unix.stat} calls. *)
  278. val stat : string -> stats
  279. (** Return the information for the named file. *)
  280. val lstat : string -> stats
  281. (** Same as {!Unix.stat}, but in case the file is a symbolic link,
  282. return the information for the link itself. *)
  283. val fstat : file_descr -> stats
  284. (** Return the information for the file associated with the given
  285. descriptor. *)
  286. val isatty : file_descr -> bool
  287. (** Return [true] if the given file descriptor refers to a terminal or
  288. console window, [false] otherwise. *)
  289. (** {6 File operations on large files} *)
  290. module LargeFile :
  291. sig
  292. val lseek : file_descr -> int64 -> seek_command -> int64
  293. val truncate : string -> int64 -> unit
  294. val ftruncate : file_descr -> int64 -> unit
  295. type stats =
  296. { st_dev : int; (** Device number *)
  297. st_ino : int; (** Inode number *)
  298. st_kind : file_kind; (** Kind of the file *)
  299. st_perm : file_perm; (** Access rights *)
  300. st_nlink : int; (** Number of links *)
  301. st_uid : int; (** User id of the owner *)
  302. st_gid : int; (** Group ID of the file's group *)
  303. st_rdev : int; (** Device minor number *)
  304. st_size : int64; (** Size in bytes *)
  305. st_atime : float; (** Last access time *)
  306. st_mtime : float; (** Last modification time *)
  307. st_ctime : float; (** Last status change time *)
  308. }
  309. val stat : string -> stats
  310. val lstat : string -> stats
  311. val fstat : file_descr -> stats
  312. end
  313. (** File operations on large files.
  314. This sub-module provides 64-bit variants of the functions
  315. {!Unix.lseek} (for positioning a file descriptor),
  316. {!Unix.truncate} and {!Unix.ftruncate} (for changing the size of a file),
  317. and {!Unix.stat}, {!Unix.lstat} and {!Unix.fstat} (for obtaining
  318. information on files). These alternate functions represent
  319. positions and sizes by 64-bit integers (type [int64]) instead of
  320. regular integers (type [int]), thus allowing operating on files
  321. whose sizes are greater than [max_int]. *)
  322. (** {6 Operations on file names} *)
  323. val unlink : string -> unit
  324. (** Removes the named file *)
  325. val rename : string -> string -> unit
  326. (** [rename old new] changes the name of a file from [old] to [new]. *)
  327. val link : string -> string -> unit
  328. (** [link source dest] creates a hard link named [dest] to the file
  329. named [source]. *)
  330. (** {6 File permissions and ownership} *)
  331. type access_permission =
  332. R_OK (** Read permission *)
  333. | W_OK (** Write permission *)
  334. | X_OK (** Execution permission *)
  335. | F_OK (** File exists *)
  336. (** Flags for the {!Unix.access} call. *)
  337. val chmod : string -> file_perm -> unit
  338. (** Change the permissions of the named file. *)
  339. val fchmod : file_descr -> file_perm -> unit
  340. (** Change the permissions of an opened file. *)
  341. val chown : string -> int -> int -> unit
  342. (** Change the owner uid and owner gid of the named file. *)
  343. val fchown : file_descr -> int -> int -> unit
  344. (** Change the owner uid and owner gid of an opened file. *)
  345. val umask : int -> int
  346. (** Set the process's file mode creation mask, and return the previous
  347. mask. *)
  348. val access : string -> access_permission list -> unit
  349. (** Check that the process has the given permissions over the named
  350. file. Raise [Unix_error] otherwise. *)
  351. (** {6 Operations on file descriptors} *)
  352. val dup : file_descr -> file_descr
  353. (** Return a new file descriptor referencing the same file as
  354. the given descriptor. *)
  355. val dup2 : file_descr -> file_descr -> unit
  356. (** [dup2 fd1 fd2] duplicates [fd1] to [fd2], closing [fd2] if already
  357. opened. *)
  358. val set_nonblock : file_descr -> unit
  359. (** Set the ``non-blocking'' flag on the given descriptor.
  360. When the non-blocking flag is set, reading on a descriptor
  361. on which there is temporarily no data available raises the
  362. [EAGAIN] or [EWOULDBLOCK] error instead of blocking;
  363. writing on a descriptor on which there is temporarily no room
  364. for writing also raises [EAGAIN] or [EWOULDBLOCK]. *)
  365. val clear_nonblock : file_descr -> unit
  366. (** Clear the ``non-blocking'' flag on the given descriptor.
  367. See {!Unix.set_nonblock}.*)
  368. val set_close_on_exec : file_descr -> unit
  369. (** Set the ``close-on-exec'' flag on the given descriptor.
  370. A descriptor with the close-on-exec flag is automatically
  371. closed when the current process starts another program with
  372. one of the [exec] functions. *)
  373. val clear_close_on_exec : file_descr -> unit
  374. (** Clear the ``close-on-exec'' flag on the given descriptor.
  375. See {!Unix.set_close_on_exec}.*)
  376. (** {6 Directories} *)
  377. val mkdir : string -> file_perm -> unit
  378. (** Create a directory with the given permissions. *)
  379. val rmdir : string -> unit
  380. (** Remove an empty directory. *)
  381. val chdir : string -> unit
  382. (** Change the process working directory. *)
  383. val getcwd : unit -> string
  384. (** Return the name of the current working directory. *)
  385. val chroot : string -> unit
  386. (** Change the process root directory. *)
  387. type dir_handle
  388. (** The type of descriptors over opened directories. *)
  389. val opendir : string -> dir_handle
  390. (** Open a descriptor on a directory *)
  391. val readdir : dir_handle -> string
  392. (** Return the next entry in a directory.
  393. @raise End_of_file when the end of the directory has been reached. *)
  394. val rewinddir : dir_handle -> unit
  395. (** Reposition the descriptor to the beginning of the directory *)
  396. val closedir : dir_handle -> unit
  397. (** Close a directory descriptor. *)
  398. (** {6 Pipes and redirections} *)
  399. val pipe : unit -> file_descr * file_descr
  400. (** Create a pipe. The first component of the result is opened
  401. for reading, that's the exit to the pipe. The second component is
  402. opened for writing, that's the entrance to the pipe. *)
  403. val mkfifo : string -> file_perm -> unit
  404. (** Create a named pipe with the given permissions. *)
  405. (** {6 High-level process and redirection management} *)
  406. val create_process :
  407. string -> string array -> file_descr -> file_descr -> file_descr -> int
  408. (** [create_process prog args new_stdin new_stdout new_stderr]
  409. forks a new process that executes the program
  410. in file [prog], with arguments [args]. The pid of the new
  411. process is returned immediately; the new process executes
  412. concurrently with the current process.
  413. The standard input and outputs of the new process are connected
  414. to the descriptors [new_stdin], [new_stdout] and [new_stderr].
  415. Passing e.g. [stdout] for [new_stdout] prevents the redirection
  416. and causes the new process to have the same standard output
  417. as the current process.
  418. The executable file [prog] is searched in the path.
  419. The new process has the same environment as the current process. *)
  420. val create_process_env :
  421. string -> string array -> string array -> file_descr -> file_descr ->
  422. file_descr -> int
  423. (** [create_process_env prog args env new_stdin new_stdout new_stderr]
  424. works as {!Unix.create_process}, except that the extra argument
  425. [env] specifies the environment passed to the program. *)
  426. val open_process_in : string -> in_channel
  427. (** High-level pipe and process management. This function
  428. runs the given command in parallel with the program.
  429. The standard output of the command is redirected to a pipe,
  430. which can be read via the returned input channel.
  431. The command is interpreted by the shell [/bin/sh] (cf. [system]). *)
  432. val open_process_out : string -> out_channel
  433. (** Same as {!Unix.open_process_in}, but redirect the standard input of
  434. the command to a pipe. Data written to the returned output channel
  435. is sent to the standard input of the command.
  436. Warning: writes on output channels are buffered, hence be careful
  437. to call {!Pervasives.flush} at the right times to ensure
  438. correct synchronization. *)
  439. val open_process : string -> in_channel * out_channel
  440. (** Same as {!Unix.open_process_out}, but redirects both the standard input
  441. and standard output of the command to pipes connected to the two
  442. returned channels. The input channel is connected to the output
  443. of the command, and the output channel to the input of the command. *)
  444. val open_process_full :
  445. string -> string array -> in_channel * out_channel * in_channel
  446. (** Similar to {!Unix.open_process}, but the second argument specifies
  447. the environment passed to the command. The result is a triple
  448. of channels connected respectively to the standard output, standard input,
  449. and standard error of the command. *)
  450. val close_process_in : in_channel -> process_status
  451. (** Close channels opened by {!Unix.open_process_in},
  452. wait for the associated command to terminate,
  453. and return its termination status. *)
  454. val close_process_out : out_channel -> process_status
  455. (** Close channels opened by {!Unix.open_process_out},
  456. wait for the associated command to terminate,
  457. and return its termination status. *)
  458. val close_process : in_channel * out_channel -> process_status
  459. (** Close channels opened by {!Unix.open_process},
  460. wait for the associated command to terminate,
  461. and return its termination status. *)
  462. val close_process_full :
  463. in_channel * out_channel * in_channel -> process_status
  464. (** Close channels opened by {!Unix.open_process_full},
  465. wait for the associated command to terminate,
  466. and return its termination status. *)
  467. (** {6 Symbolic links} *)
  468. val symlink : string -> string -> unit
  469. (** [symlink source dest] creates the file [dest] as a symbolic link
  470. to the file [source]. *)
  471. val readlink : string -> string
  472. (** Read the contents of a link. *)
  473. (** {6 Polling} *)
  474. val select :
  475. file_descr list -> file_descr list -> file_descr list -> float ->
  476. file_descr list * file_descr list * file_descr list
  477. (** Wait until some input/output operations become possible on
  478. some channels. The three list arguments are, respectively, a set
  479. of descriptors to check for reading (first argument), for writing
  480. (second argument), or for exceptional conditions (third argument).
  481. The fourth argument is the maximal timeout, in seconds; a
  482. negative fourth argument means no timeout (unbounded wait).
  483. The result is composed of three sets of descriptors: those ready
  484. for reading (first component), ready for writing (second component),
  485. and over which an exceptional condition is pending (third
  486. component). *)
  487. (** {6 Locking} *)
  488. type lock_command =
  489. F_ULOCK (** Unlock a region *)
  490. | F_LOCK (** Lock a region for writing, and block if already locked *)
  491. | F_TLOCK (** Lock a region for writing, or fail if already locked *)
  492. | F_TEST (** Test a region for other process locks *)
  493. | F_RLOCK (** Lock a region for reading, and block if already locked *)
  494. | F_TRLOCK (** Lock a region for reading, or fail if already locked *)
  495. (** Commands for {!Unix.lockf}. *)
  496. val lockf : file_descr -> lock_command -> int -> unit
  497. (** [lockf fd cmd size] puts a lock on a region of the file opened
  498. as [fd]. The region starts at the current read/write position for
  499. [fd] (as set by {!Unix.lseek}), and extends [size] bytes forward if
  500. [size] is positive, [size] bytes backwards if [size] is negative,
  501. or to the end of the file if [size] is zero.
  502. A write lock prevents any other
  503. process from acquiring a read or write lock on the region.
  504. A read lock prevents any other
  505. process from acquiring a write lock on the region, but lets
  506. other processes acquire read locks on it.
  507. The [F_LOCK] and [F_TLOCK] commands attempts to put a write lock
  508. on the specified region.
  509. The [F_RLOCK] and [F_TRLOCK] commands attempts to put a read lock
  510. on the specified region.
  511. If one or several locks put by another process prevent the current process
  512. from acquiring the lock, [F_LOCK] and [F_RLOCK] block until these locks
  513. are removed, while [F_TLOCK] and [F_TRLOCK] fail immediately with an
  514. exception.
  515. The [F_ULOCK] removes whatever locks the current process has on
  516. the specified region.
  517. Finally, the [F_TEST] command tests whether a write lock can be
  518. acquired on the specified region, without actually putting a lock.
  519. It returns immediately if successful, or fails otherwise. *)
  520. (** {6 Signals}
  521. Note: installation of signal handlers is performed via
  522. the functions {!Sys.signal} and {!Sys.set_signal}.
  523. *)
  524. val kill : int -> int -> unit
  525. (** [kill pid sig] sends signal number [sig] to the process
  526. with id [pid]. *)
  527. type sigprocmask_command =
  528. SIG_SETMASK
  529. | SIG_BLOCK
  530. | SIG_UNBLOCK
  531. val sigprocmask : sigprocmask_command -> int list -> int list
  532. (** [sigprocmask cmd sigs] changes the set of blocked signals.
  533. If [cmd] is [SIG_SETMASK], blocked signals are set to those in
  534. the list [sigs].
  535. If [cmd] is [SIG_BLOCK], the signals in [sigs] are added to
  536. the set of blocked signals.
  537. If [cmd] is [SIG_UNBLOCK], the signals in [sigs] are removed
  538. from the set of blocked signals.
  539. [sigprocmask] returns the set of previously blocked signals. *)
  540. val sigpending : unit -> int list
  541. (** Return the set of blocked signals that are currently pending. *)
  542. val sigsuspend : int list -> unit
  543. (** [sigsuspend sigs] atomically sets the blocked signals to [sigs]
  544. and waits for a non-ignored, non-blocked signal to be delivered.
  545. On return, the blocked signals are reset to their initial value. *)
  546. val pause : unit -> unit
  547. (** Wait until a non-ignored, non-blocked signal is delivered. *)
  548. (** {6 Time functions} *)
  549. type process_times =
  550. { tms_utime : float; (** User time for the process *)
  551. tms_stime : float; (** System time for the process *)
  552. tms_cutime : float; (** User time for the children processes *)
  553. tms_cstime : float; (** System time for the children processes *)
  554. }
  555. (** The execution times (CPU times) of a process. *)
  556. type tm =
  557. { tm_sec : int; (** Seconds 0..60 *)
  558. tm_min : int; (** Minutes 0..59 *)
  559. tm_hour : int; (** Hours 0..23 *)
  560. tm_mday : int; (** Day of month 1..31 *)
  561. tm_mon : int; (** Month of year 0..11 *)
  562. tm_year : int; (** Year - 1900 *)
  563. tm_wday : int; (** Day of week (Sunday is 0) *)
  564. tm_yday : int; (** Day of year 0..365 *)
  565. tm_isdst : bool; (** Daylight time savings in effect *)
  566. }
  567. (** The type representing wallclock time and calendar date. *)
  568. val time : unit -> float
  569. (** Return the current time since 00:00:00 GMT, Jan. 1, 1970,
  570. in seconds. *)
  571. val gettimeofday : unit -> float
  572. (** Same as {!Unix.time}, but with resolution better than 1 second. *)
  573. val gmtime : float -> tm
  574. (** Convert a time in seconds, as returned by {!Unix.time}, into a date and
  575. a time. Assumes UTC (Coordinated Universal Time), also known as GMT. *)
  576. val localtime : float -> tm
  577. (** Convert a time in seconds, as returned by {!Unix.time}, into a date and
  578. a time. Assumes the local time zone. *)
  579. val mktime : tm -> float * tm
  580. (** Convert a date and time, specified by the [tm] argument, into
  581. a time in seconds, as returned by {!Unix.time}. The [tm_isdst],
  582. [tm_wday] and [tm_yday] fields of [tm] are ignored. Also return a
  583. normalized copy of the given [tm] record, with the [tm_wday],
  584. [tm_yday], and [tm_isdst] fields recomputed from the other fields,
  585. and the other fields normalized (so that, e.g., 40 October is
  586. changed into 9 November). The [tm] argument is interpreted in the
  587. local time zone. *)
  588. val alarm : int -> int
  589. (** Schedule a [SIGALRM] signal after the given number of seconds. *)
  590. val sleep : int -> unit
  591. (** Stop execution for the given number of seconds. *)
  592. val times : unit -> process_times
  593. (** Return the execution times of the process. *)
  594. val utimes : string -> float -> float -> unit
  595. (** Set the last access time (second arg) and last modification time
  596. (third arg) for a file. Times are expressed in seconds from
  597. 00:00:00 GMT, Jan. 1, 1970. A time of [0.0] is interpreted as the
  598. current time. *)
  599. type interval_timer =
  600. ITIMER_REAL
  601. (** decrements in real time, and sends the signal [SIGALRM] when
  602. expired.*)
  603. | ITIMER_VIRTUAL
  604. (** decrements in process virtual time, and sends [SIGVTALRM]
  605. when expired. *)
  606. | ITIMER_PROF
  607. (** (for profiling) decrements both when the process
  608. is running and when the system is running on behalf of the
  609. process; it sends [SIGPROF] when expired. *)
  610. (** The three kinds of interval timers. *)
  611. type interval_timer_status =
  612. { it_interval : float; (** Period *)
  613. it_value : float; (** Current value of the timer *)
  614. }
  615. (** The type describing the status of an interval timer *)
  616. val getitimer : interval_timer -> interval_timer_status
  617. (** Return the current status of the given interval timer. *)
  618. val setitimer :
  619. interval_timer -> interval_timer_status -> interval_timer_status
  620. (** [setitimer t s] sets the interval timer [t] and returns
  621. its previous status. The [s] argument is interpreted as follows:
  622. [s.it_value], if nonzero, is the time to the next timer expiration;
  623. [s.it_interval], if nonzero, specifies a value to
  624. be used in reloading it_value when the timer expires.
  625. Setting [s.it_value] to zero disable the timer.
  626. Setting [s.it_interval] to zero causes the timer to be disabled
  627. after its next expiration. *)
  628. (** {6 User id, group id} *)
  629. val getuid : unit -> int
  630. (** Return the user id of the user executing the process. *)
  631. val geteuid : unit -> int
  632. (** Return the effective user id under which the process runs. *)
  633. val setuid : int -> unit
  634. (** Set the real user id and effective user id for the process. *)
  635. val getgid : unit -> int
  636. (** Return the group id of the user executing the process. *)
  637. val getegid : unit -> int
  638. (** Return the effective group id under which the process runs. *)
  639. val setgid : int -> unit
  640. (** Set the real group id and effective group id for the process. *)
  641. val getgroups : unit -> int array
  642. (** Return the list of groups to which the user executing the process
  643. belongs. *)
  644. val setgroups : int array -> unit
  645. (** [setgroups groups] sets the supplementary group IDs for the
  646. calling process. Appropriate privileges are required. *)
  647. val initgroups : string -> int -> unit
  648. (** [initgroups user group] initializes the group access list by
  649. reading the group database /etc/group and using all groups of
  650. which [user] is a member. The additional group [group] is also
  651. added to the list. *)
  652. type passwd_entry =
  653. { pw_name : string;
  654. pw_passwd : string;
  655. pw_uid : int;
  656. pw_gid : int;
  657. pw_gecos : string;
  658. pw_dir : string;
  659. pw_shell : string
  660. }
  661. (** Structure of entries in the [passwd] database. *)
  662. type group_entry =
  663. { gr_name : string;
  664. gr_passwd : string;
  665. gr_gid : int;
  666. gr_mem : string array
  667. }
  668. (** Structure of entries in the [groups] database. *)
  669. val getlogin : unit -> string
  670. (** Return the login name of the user executing the process. *)
  671. val getpwnam : string -> passwd_entry
  672. (** Find an entry in [passwd] with the given name, or raise
  673. [Not_found]. *)
  674. val getgrnam : string -> group_entry
  675. (** Find an entry in [group] with the given name, or raise
  676. [Not_found]. *)
  677. val getpwuid : int -> passwd_entry
  678. (** Find an entry in [passwd] with the given user id, or raise
  679. [Not_found]. *)
  680. val getgrgid : int -> group_entry
  681. (** Find an entry in [group] with the given group id, or raise
  682. [Not_found]. *)
  683. (** {6 Internet addresses} *)
  684. type inet_addr
  685. (** The abstract type of Internet addresses. *)
  686. val inet_addr_of_string : string -> inet_addr
  687. (** Conversion from the printable representation of an Internet
  688. address to its internal representation. The argument string
  689. consists of 4 numbers separated by periods ([XXX.YYY.ZZZ.TTT])
  690. for IPv4 addresses, and up to 8 numbers separated by colons
  691. for IPv6 addresses. Raise [Failure] when given a string that
  692. does not match these formats. *)
  693. val string_of_inet_addr : inet_addr -> string
  694. (** Return the printable representation of the given Internet address.
  695. See {!Unix.inet_addr_of_string} for a description of the
  696. printable representation. *)
  697. val inet_addr_any : inet_addr
  698. (** A special IPv4 address, for use only with [bind], representing
  699. all the Internet addresses that the host machine possesses. *)
  700. val inet_addr_loopback : inet_addr
  701. (** A special IPv4 address representing the host machine ([127.0.0.1]). *)
  702. val inet6_addr_any : inet_addr
  703. (** A special IPv6 address, for use only with [bind], representing
  704. all the Internet addresses that the host machine possesses. *)
  705. val inet6_addr_loopback : inet_addr
  706. (** A special IPv6 address representing the host machine ([::1]). *)
  707. (** {6 Sockets} *)
  708. type socket_domain =
  709. PF_UNIX (** Unix domain *)
  710. | PF_INET (** Internet domain (IPv4) *)
  711. | PF_INET6 (** Internet domain (IPv6) *)
  712. (** The type of socket domains. Not all platforms support
  713. IPv6 sockets (type [PF_INET6]). *)
  714. type socket_type =
  715. SOCK_STREAM (** Stream socket *)
  716. | SOCK_DGRAM (** Datagram socket *)
  717. | SOCK_RAW (** Raw socket *)
  718. | SOCK_SEQPACKET (** Sequenced packets socket *)
  719. (** The type of socket kinds, specifying the semantics of
  720. communications. *)
  721. type sockaddr =
  722. ADDR_UNIX of string
  723. | ADDR_INET of inet_addr * int
  724. (** The type of socket addresses. [ADDR_UNIX name] is a socket
  725. address in the Unix domain; [name] is a file name in the file
  726. system. [ADDR_INET(addr,port)] is a socket address in the Internet
  727. domain; [addr] is the Internet address of the machine, and
  728. [port] is the port number. *)
  729. val socket : socket_domain -> socket_type -> int -> file_descr
  730. (** Create a new socket in the given domain, and with the
  731. given kind. The third argument is the protocol type; 0 selects
  732. the default protocol for that kind of sockets. *)
  733. val domain_of_sockaddr: sockaddr -> socket_domain
  734. (** Return the socket domain adequate for the given socket address. *)
  735. val socketpair :
  736. socket_domain -> socket_type -> int -> file_descr * file_descr
  737. (** Create a pair of unnamed sockets, connected together. *)
  738. val accept : file_descr -> file_descr * sockaddr
  739. (** Accept connections on the given socket. The returned descriptor
  740. is a socket connected to the client; the returned address is
  741. the address of the connecting client. *)
  742. val bind : file_descr -> sockaddr -> unit
  743. (** Bind a socket to an address. *)
  744. val connect : file_descr -> sockaddr -> unit
  745. (** Connect a socket to an address. *)
  746. val listen : file_descr -> int -> unit
  747. (** Set up a socket for receiving connection requests. The integer
  748. argument is the maximal number of pending requests. *)
  749. type shutdown_command =
  750. SHUTDOWN_RECEIVE (** Close for receiving *)
  751. | SHUTDOWN_SEND (** Close for sending *)
  752. | SHUTDOWN_ALL (** Close both *)
  753. (** The type of commands for [shutdown]. *)
  754. val shutdown : file_descr -> shutdown_command -> unit
  755. (** Shutdown a socket connection. [SHUTDOWN_SEND] as second argument
  756. causes reads on the other end of the connection to return
  757. an end-of-file condition.
  758. [SHUTDOWN_RECEIVE] causes writes on the other end of the connection
  759. to return a closed pipe condition ([SIGPIPE] signal). *)
  760. val getsockname : file_descr -> sockaddr
  761. (** Return the address of the given socket. *)
  762. val getpeername : file_descr -> sockaddr
  763. (** Return the address of the host connected to the given socket. *)
  764. type msg_flag =
  765. MSG_OOB
  766. | MSG_DONTROUTE
  767. | MSG_PEEK
  768. (** The flags for {!Unix.recv}, {!Unix.recvfrom},
  769. {!Unix.send} and {!Unix.sendto}. *)
  770. val recv : file_descr -> string -> int -> int -> msg_flag list -> int
  771. (** Receive data from a connected socket. *)
  772. val recvfrom :
  773. file_descr -> string -> int -> int -> msg_flag list -> int * sockaddr
  774. (** Receive data from an unconnected socket. *)
  775. val send : file_descr -> string -> int -> int -> msg_flag list -> int
  776. (** Send data over a connected socket. *)
  777. val sendto :
  778. file_descr -> string -> int -> int -> msg_flag list -> sockaddr -> int
  779. (** Send data over an unconnected socket. *)
  780. (** {6 Socket options} *)
  781. type socket_bool_option =
  782. SO_DEBUG (** Record debugging information *)
  783. | SO_BROADCAST (** Permit sending of broadcast messages *)
  784. | SO_REUSEADDR (** Allow reuse of local addresses for bind *)
  785. | SO_KEEPALIVE (** Keep connection active *)
  786. | SO_DONTROUTE (** Bypass the standard routing algorithms *)
  787. | SO_OOBINLINE (** Leave out-of-band data in line *)
  788. | SO_ACCEPTCONN (** Report whether socket listening is enabled *)
  789. | TCP_NODELAY (** Control the Nagle algorithm for TCP sockets *)
  790. | IPV6_ONLY (** Forbid binding an IPv6 socket to an IPv4 address *)
  791. (** The socket options that can be consulted with {!Unix.getsockopt}
  792. and modified with {!Unix.setsockopt}. These options have a boolean
  793. ([true]/[false]) value. *)
  794. type socket_int_option =
  795. SO_SNDBUF (** Size of send buffer *)
  796. | SO_RCVBUF (** Size of received buffer *)
  797. | SO_ERROR (** Deprecated. Use {!Unix.getsockopt_error} instead. *)
  798. | SO_TYPE (** Report the socket type *)
  799. | SO_RCVLOWAT (** Minimum number of bytes to process for input operations*)
  800. | SO_SNDLOWAT (** Minimum number of bytes to process for output
  801. operations *)
  802. (** The socket options that can be consulted with {!Unix.getsockopt_int}
  803. and modified with {!Unix.setsockopt_int}. These options have an
  804. integer value. *)
  805. type socket_optint_option =
  806. SO_LINGER (** Whether to linger on closed connections
  807. that have data present, and for how long
  808. (in seconds) *)
  809. (** The socket options that can be consulted with {!Unix.getsockopt_optint}
  810. and modified with {!Unix.setsockopt_optint}. These options have a
  811. value of type [int option], with [None] meaning ``disabled''. *)
  812. type socket_float_option =
  813. SO_RCVTIMEO (** Timeout for input operations *)
  814. | SO_SNDTIMEO (** Timeout for output operations *)
  815. (** The socket options that can be consulted with {!Unix.getsockopt_float}
  816. and modified with {!Unix.setsockopt_float}. These options have a
  817. floating-point value representing a time in seconds.
  818. The value 0 means infinite timeout. *)
  819. val getsockopt : file_descr -> socket_bool_option -> bool
  820. (** Return the current status of a boolean-valued option
  821. in the given socket. *)
  822. val setsockopt : file_descr -> socket_bool_option -> bool -> unit
  823. (** Set or clear a boolean-valued option in the given socket. *)
  824. val getsockopt_int : file_descr -> socket_int_option -> int
  825. (** Same as {!Unix.getsockopt} for an integer-valued socket option. *)
  826. val setsockopt_int : file_descr -> socket_int_option -> int -> unit
  827. (** Same as {!Unix.setsockopt} for an integer-valued socket option. *)
  828. val getsockopt_optint : file_descr -> socket_optint_option -> int option
  829. (** Same as {!Unix.getsockopt} for a socket option whose value is an
  830. [int option]. *)
  831. val setsockopt_optint :
  832. file_descr -> socket_optint_option -> int option -> unit
  833. (** Same as {!Unix.setsockopt} for a socket option whose value is an
  834. [int option]. *)
  835. val getsockopt_float : file_descr -> socket_float_option -> float
  836. (** Same as {!Unix.getsockopt} for a socket option whose value is a
  837. floating-point number. *)
  838. val setsockopt_float : file_descr -> socket_float_option -> float -> unit
  839. (** Same as {!Unix.setsockopt} for a socket option whose value is a
  840. floating-point number. *)
  841. val getsockopt_error : file_descr -> error option
  842. (** Return the error condition associated with the given socket,
  843. and clear it. *)
  844. (** {6 High-level network connection functions} *)
  845. val open_connection : sockaddr -> in_channel * out_channel
  846. (** Connect to a server at the given address.
  847. Return a pair of buffered channels connected to the server.
  848. Remember to call {!Pervasives.flush} on the output channel at the right
  849. times to ensure correct synchronization. *)
  850. val shutdown_connection : in_channel -> unit
  851. (** ``Shut down'' a connection established with {!Unix.open_connection};
  852. that is, transmit an end-of-file condition to the server reading
  853. on the other side of the connection. *)
  854. val establish_server : (in_channel -> out_channel -> unit) -> sockaddr -> unit
  855. (** Establish a server on the given address.
  856. The function given as first argument is called for each connection
  857. with two buffered channels connected to the client. A new process
  858. is created for each connection. The function {!Unix.establish_server}
  859. never returns normally. *)
  860. (** {6 Host and protocol databases} *)
  861. type host_entry =
  862. { h_name : string;
  863. h_aliases : string array;
  864. h_addrtype : socket_domain;
  865. h_addr_list : inet_addr array
  866. }
  867. (** Structure of entries in the [hosts] database. *)
  868. type protocol_entry =
  869. { p_name : string;
  870. p_aliases : string array;
  871. p_proto : int
  872. }
  873. (** Structure of entries in the [protocols] database. *)
  874. type service_entry =
  875. { s_name : string;
  876. s_aliases : string array;
  877. s_port : int;
  878. s_proto : string
  879. }
  880. (** Structure of entries in the [services] database. *)
  881. val gethostname : unit -> string
  882. (** Return the name of the local host. *)
  883. val gethostbyname : string -> host_entry
  884. (** Find an entry in [hosts] with the given name, or raise
  885. [Not_found]. *)
  886. val gethostbyaddr : inet_addr -> host_entry
  887. (** Find an entry in [hosts] with the given address, or raise
  888. [Not_found]. *)
  889. val getprotobyname : string -> protocol_entry
  890. (** Find an entry in [protocols] with the given name, or raise
  891. [Not_found]. *)
  892. val getprotobynumber : int -> protocol_entry
  893. (** Find an entry in [protocols] with the given protocol number,
  894. or raise [Not_found]. *)
  895. val getservbyname : string -> string -> service_entry
  896. (** Find an entry in [services] with the given name, or raise
  897. [Not_found]. *)
  898. val getservbyport : int -> string -> service_entry
  899. (** Find an entry in [services] with the given service number,
  900. or raise [Not_found]. *)
  901. type addr_info =
  902. { ai_family : socket_domain; (** Socket domain *)
  903. ai_socktype : socket_type; (** Socket type *)
  904. ai_protocol : int; (** Socket protocol number *)
  905. ai_addr : sockaddr; (** Address *)
  906. ai_canonname : string (** Canonical host name *)
  907. }
  908. (** Address information returned by {!Unix.getaddrinfo}. *)
  909. type getaddrinfo_option =
  910. AI_FAMILY of socket_domain (** Impose the given socket domain *)
  911. | AI_SOCKTYPE of socket_type (** Impose the given socket type *)
  912. | AI_PROTOCOL of int (** Impose the given protocol *)
  913. | AI_NUMERICHOST (** Do not call name resolver,
  914. expect numeric IP address *)
  915. | AI_CANONNAME (** Fill the [ai_canonname] field
  916. of the result *)
  917. | AI_PASSIVE (** Set address to ``any'' address
  918. for use with {!Unix.bind} *)
  919. (** Options to {!Unix.getaddrinfo}. *)
  920. val getaddrinfo:
  921. string -> string -> getaddrinfo_option list -> addr_info list
  922. (** [getaddrinfo host service opts] returns a list of {!Unix.addr_info}
  923. records describing socket parameters and addresses suitable for
  924. communicating with the given host and service. The empty list is
  925. returned if the host or service names are unknown, or the constraints
  926. expressed in [opts] cannot be satisfied.
  927. [host] is either a host name or the string representation of an IP
  928. address. [host] can be given as the empty string; in this case,
  929. the ``any'' address or the ``loopback'' address are used,
  930. depending whether [opts] contains [AI_PASSIVE].
  931. [service] is either a service name or the string representation of
  932. a port number. [service] can be given as the empty string;
  933. in this case, the port field of the returned addresses is set to 0.
  934. [opts] is a possibly empty list of options that allows the caller
  935. to force a particular socket domain (e.g. IPv6 only or IPv4 only)
  936. or a particular socket type (e.g. TCP only or UDP only). *)
  937. type name_info =
  938. { ni_hostname : string; (** Name or IP address of host *)
  939. ni_service : string } (** Name of service or port number *)
  940. (** Host and service information returned by {!Unix.getnameinfo}. *)
  941. type getnameinfo_option =
  942. NI_NOFQDN (** Do not qualify local host names *)
  943. | NI_NUMERICHOST (** Always return host as IP address *)
  944. | NI_NAMEREQD (** Fail if host name cannot be determined *)
  945. | NI_NUMERICSERV (** Always return service as port number *)
  946. | NI_DGRAM (** Consider the service as UDP-based
  947. instead of the default TCP *)
  948. (** Options to {!Unix.getnameinfo}. *)
  949. val getnameinfo : sockaddr -> getnameinfo_option list -> name_info
  950. (** [getnameinfo addr opts] returns the host name and service name
  951. corresponding to the socket address [addr]. [opts] is a possibly
  952. empty list of options that governs how these names are obtained.
  953. Raise [Not_found] if an error occurs. *)
  954. (** {6 Terminal interface} *)
  955. (** The following functions implement the POSIX standard terminal
  956. interface. They provide control over asynchronous communication ports
  957. and pseudo-terminals. Refer to the [termios] man page for a
  958. complete description. *)
  959. type terminal_io =
  960. {
  961. (* input modes *)
  962. mutable c_ignbrk : bool; (** Ignore the break condition. *)
  963. mutable c_brkint : bool; (** Signal interrupt on break condition. *)
  964. mutable c_ignpar : bool; (** Ignore characters with parity errors. *)
  965. mutable c_parmrk : bool; (** Mark parity errors. *)
  966. mutable c_inpck : bool; (** Enable parity check on input. *)
  967. mutable c_istrip : bool; (** Strip 8th bit on input characters. *)
  968. mutable c_inlcr : bool; (** Map NL to CR on input. *)
  969. mutable c_igncr : bool; (** Ignore CR on input. *)
  970. mutable c_icrnl : bool; (** Map CR to NL on input. *)
  971. mutable c_ixon : bool; (** Recognize XON/XOFF characters on input. *)
  972. mutable c_ixoff : bool; (** Emit XON/XOFF chars to control input flow. *)
  973. (* Output modes: *)
  974. mutable c_opost : bool; (** Enable output processing. *)
  975. (* Control modes: *)
  976. mutable c_obaud : int; (** Output baud rate (0 means close connection).*)
  977. mutable c_ibaud : int; (** Input baud rate. *)
  978. mutable c_csize : int; (** Number of bits per character (5-8). *)
  979. mutable c_cstopb : int; (** Number of stop bits (1-2). *)
  980. mutable c_cread : bool; (** Reception is enabled. *)
  981. mutable c_parenb : bool; (** Enable parity generation and detection. *)
  982. mutable c_parodd : bool; (** Specify odd parity instead of even. *)
  983. mutable c_hupcl : bool; (** Hang up on last close. *)
  984. mutable c_clocal : bool; (** Ignore modem status lines. *)
  985. (* Local modes: *)
  986. mutable c_isig : bool; (** Generate signal on INTR, QUIT, SUSP. *)
  987. mutable c_icanon : bool; (** Enable canonical processing
  988. (line buffering and editing) *)
  989. mutable c_noflsh : bool; (** Disable flush after INTR, QUIT, SUSP. *)
  990. mutable c_echo : b