OS2/emx/syscall/_pipe

OS2/emx/syscall/_pipe

emx 内部ではネームドパイプを使って実装されているみたいです。

emx/src/os2/fileio.c から:

int do_pipe (int *dst, ULONG pipesize)
{
  HPIPE r_handle, w_handle, nh;
  ULONG rc, action, pn;
  char fname[128];
  int e;

  /* Create unique a pipe name (unique on this system). */

  LOCK_COMMON;
  pn = ++pipe_number;
  UNLOCK_COMMON;
  sprintf (fname, "/pipe/emx/pipes/%.8x.pip", (unsigned)pn);

  /* Create the pipe. */

  rc = DosCreateNPipe (fname, &r_handle,
                       NP_ACCESS_INBOUND,
                       1 | NP_NOWAIT | NP_TYPE_BYTE | NP_READMODE_BYTE,
                       pipesize, pipesize, 0);
  if (rc != 0)
    return set_error (rc);

  /* Connect to the pipe. */

  rc = DosConnectNPipe (r_handle);
  if (rc != 0 && rc != ERROR_PIPE_NOT_CONNECTED)
    {
      DosClose (r_handle);
      return set_error (rc);
    }

  /* Turn on NP_WAIT. */

  rc = DosSetNPHState (r_handle, NP_WAIT | NP_READMODE_BYTE);
  if (rc != 0)
    {
      DosClose (r_handle);
      return set_error (rc);
    }

  /* Open the write side of the pipe. */

  rc = DosOpen (fname, &w_handle, &action, 0, FILE_NORMAL,
                OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW,
                OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYREADWRITE,
                NULL);
  if (rc != 0)
    {
      DosClose (r_handle);
      return set_error (rc);
    }

  /* Update the file handle table. */

  e = reloc_handle (r_handle, &nh, TRUE);
  if (e != 0)
    {
      DosClose (r_handle);
      DosClose (w_handle);
      return e;
    }
  r_handle = nh;

  e = reloc_handle (w_handle, &nh, TRUE);
  if (e != 0)
    {
      DosClose (r_handle);
      DosClose (w_handle);
      return e;
    }
  w_handle = nh;

  /* Set DST handles. */

  dst[0] = r_handle;
  dst[1] = w_handle;
  return 0;
}