.
Last update: 1997-05-20
14519-92 #3 Class: Editorial defect _____________________________________________________________________________ Topic: Text on writing to pipe Relevant Sections: ISO/IEC 14519:1994, section 6.1.2, ISO/IEC 9945-1:1990, section 6.4.2.2 Defect Report: ----------------------- The text in ISO/IEC 14519 does not fully specify the behavior on writing to a pipe, as specified by ISO/IEC 9945-1. WG15 response for 9945-1:1990 (9945-1:1990): -------------------------------------------------- The behavior specified by POSIX.1 for reading from a pipe (POSIX.1 section 6.4.2.2, lines 228-253) also apply to POSIX.5. In particular, the following text from POSIX.1 applies: Write requests to a pipe (or FIFO) shall be handled in the same manner as write requests to a regular file, with the following exceptions: (1) There is no file offset associated with a pipe, hence each write request shall append to the end of the pipe. (2) Write requests of {PIPE_BUF} byte or less shall not be interleaved with data from other processes doing writes on the same pipe. Writes of greater than {PIPE_BUF} bytes may have data interleaved, on arbitrary boundaries, with writes by other processes, whether or not the O_NONBLOCK flag of the file status flags is set. (3) If the O_NONBLOCK flag is clear, a write request may cause the process to block, but on normal completion it shall return nbytes. (4) If the O_NONBLOCK flag is set, write() requests shall be handled differently, in the following ways: (a) The write() function shall not block the process. (b) A write request for {PIPE_BUF} or fewer bytes shall either: [1] If there is sufficient space available in the pipe, transfer all the data and return the number of bytes requested. [2] If there is not sufficient space available in the pipe, transfer no data and return -1 with errno set to [EAGAIN]. (c) A write request for more than {PIPE_BUF} bytes shall either: [1] When at least one byte can be written, transfer what it can and return the number of bytes written. When all data previously written to the pipe has been read, it shall transfer at least {PIPE_BUF} bytes. [2] When no data can be written, transfer no data and return -1 with errno set to [EAGAIN]. The following text indicates the exact semantics of the Ada binding to the POSIX.1 semantics: All writes to a pipe shall be appended to the end of the pipe. If POSIX_Configurable_File_Limits.Pipe_Length_Is_Limited returns True when applied to the file descriptor representing the pipe, then the following rules apply, where PIPE_MAX reflects the value returned by POSIX_Configurable_File_Limits.Pipe_Length_Limit applied to the file descriptor representing the pipe. (1) If Buffer'Length < PIPE_MAX, then the contents of Buffer shall not be interleaved with data from other processes doing writes on the same pipe. (2) If Buffer'length > PIPE_MAX, the contents of Buffer may be interleaved, on arbitrary boundaries, with data written by other processes. This behavior is independent of the Non_Blocking option established for the pipe when it is created/opened. (3) If the Non_Blocking option is not in effect for the pipe, a write request may <or "shall", .1 says "may", but I'm not sure I believe this...> cause the process to block. (4) If the Non_Blocking option is in effect for the pipe, and Buffer'Length < PIPE_MAX, one of the following shall occur: (a) If there is sufficient space available in the pipe, the contents of Buffer shall be written to the pipe. (b) If there is not sufficient space available in the pipe, no data shall be transferred, and Write shall raise POSIX_Error with the error code Interrupted_Operation. (5) If the Non_Blocking option is in effect for the pipe, and Buffer'Length > PIPE_MAX, one of the following shall occur: (a) If at least one element can be written, the Write operation shall transfer as much of the contents of Buffer as can be written. When all data previously written to the pipe has been read, Write shall transfer at least PIPE_MAX elements of Buffer before returning. (b) When no data can be written to the pipe, no data shall be transferred, and Write shall raise POSIX_Error with the error code Interrupted Operation. If POSIX_Configurable_File_Limits.Pipe_Length_Is_Limited returns False when applied to the file descriptor representing the pipe, then the behavior shall be that specified for Buffer'Length < PIPE_MAX, regardless of the actual value of Buffer'Length. Rationale for Interpretation: ----------------------------- The intent for POSIX.5 is to match the POSIX.1 semantics. The text on writing to a pipe was omitted from POSIX.5. As written, POSIX.5 does not contradict this text, and this behavior is generally implied by other wording in the section, and the general mapping of POSIX.1 semantics in Ada. Editorial note for future revision of standard (not part of the interpretation) ------------------------------------------------------------------------------- This will be included in the 14519 revision. _____________________________________________________________________________