DosClose closes the specified pipe handle. When all of the handles that access one end of a pipe have been closed, the pipe is referred to as a broken pipe.
If the client end of the pipe closes, no other process can reopen the pipe until the server calls DosDisConnectNPipe (to acknowledge the client's close) followed by DosConnectNPipe (to prepare the pipe for a new client). Until it calls DosDisConnectNPipe, the server will receive ERROR_EOF if it tries to read from the pipe, and ERROR_BROKEN_PIPE if it tries to write to it. Clients that attempt to open the pipe receive ERROR_PIPE_BUSY.
If the server end closes when the client end is already closed, the pipe is deallocated immediately; otherwise, the pipe is not deallocated until the last client handle is closed.
The following code fragment shows how to close a named pipe. Assume that a previous call to DosOpen provided the named pipe handle that is contained in Handle.
#define INCL_DOSNMPIPES /* Named-pipe values */ #include <os2.h> #include <stdio.h> HPIPE hpHandle; /* Pipe handle */ APIRET ulrc; /* Return code */ ulrc = DosDisConnectNPipe(hpHandle); if (ulrc != 0) { printf("DosDisConnectNPipe error: return code = %ld", ulrc); return; }