HP3000-L Archives

January 1999, Week 5

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Bixby <[log in to unmask]>
Reply To:
Date:
Fri, 29 Jan 1999 11:34:03 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (123 lines)
Dirickson Robert S writes:
>
> I'm trying to use the subject intrinsic, and not having much luck. Since the
> statement "HP's documentation on HPPIPE is a bit skimpy" is a solid
> contender for the "Understatement of the Year" award, I'd appreciate hearing
> from anyone who is successfully using this facility for inter-process
> communication. Thanks.

See below for the HPUX 10.20 man page for the pipe() function.

The POSIX pipe() function essentially creates two special unnamed open files --
the read end of the pipe, and the write end of the pipe.  Data written on one
end is readable at the other end.  In the POSIX environment of a parent process
communicating with a child process, the parent calls pipe(), then fork()s a
child which inherits all open file descriptors of the parent, including those
created by pipe().  The child writes to the write side of the pipe, and the
parent reads from the read side.

I think that POSIX pipe() simply calls HPPIPE and does return status translation
from hpestatus to errno.

I strongly doubt that HPPIPE will be of any use to you in a traditional MPE
CREATEPROCESS environment, because CREATEPROCESS doesn't pass the parent's open
files to the child.

From what I know about fork(), trying to call it from an MPE non-POSIX program
would probably not be supported, and in any case would be asking for a whole
lot of trouble!

- Mark

 NAME
      pipe - create an interprocess channel

 SYNOPSIS
      int pipe(int fildes[2]);

 DESCRIPTION
      pipe() creates an I/O mechanism called a pipe and returns two file
      descriptors, fildes[0] and fildes[1].  fildes[0] is opened for reading
      and fildes[1] is opened for writing.

      A read-only file descriptor fildes[0] accesses the data written to
      fildes[1] on a first-in-first-out (FIFO) basis.  For details of the
      I/O behavior of pipes see read(2) and write(2).

      By default, HP-UX pipes are not STREAMS-based.  It is possible to
      generate the kernel so that all pipes created on a system are
      STREAMS-based.  This can only be done for HP-UX releases 10.0 and
      later.  STREAMS-based FIFOs (created by mknod or mkfifo) are not
      supported on HP-UX.

      To generate a kernel that supports STREAMS-based pipes:

      +  STREAMS/UX must be installed.

      +  The module pipemod and the driver pipedev must be included in the
         /stand/system file.  (When STREAMS/UX is installed, pipemod and
         pipedev are automatically added to the system file.)

      +  The tunable parameter "streampipes" must be set to 1 in the
         /stand/system file.  (This is not automatically done when
         STREAMS/UX is installed.)

      +  The kernel must be generated and the system rebooted.  Once this is
         done, all pipes created by pipe() will be STREAMS-based.

      For more information, see STREAMS/UX for the HP 9000 Reference Manual.

 EXAMPLES
      The following example uses pipe() to implement the command string ls |
      sort:

           #include <sys/types.h>
           pid_t pid;
           int pipefd[2];

           /*  Assumes file descriptor 0 and 1 are open  */
           pipe (pipefd);

           if ((pid = fork()) == (pid_t)0) /* check process id of child process */ {
                close(1);      /* close stdout */
                dup (pipefd[1]); /* points pipefd at file descriptor */
                close (pipefd[0]);
                execlp ("ls", "ls", (char *)0);  /* child process does ls */
           }
           else if (pid > (pid_t)0) {
                close(0); /* close stdin  */
                dup (pipefd[0]);
                /* point the child's standard output to parent's standard input */
                close (pipefd[1]);
                execlp ("sort", "sort", (char *)0); /* parent process does sort */
           }

 RETURN VALUE
      Upon successful completion, a value of 0 is returned.  Otherwise, a
      value of -1 is returned and errno is set to indicate the error.

 ERRORS
      pipe() fails if one or more of the following is true:

      [EMFILE]       NFILE-1 or more file descriptors are currently open.

      [ENFILE]       The system file table is full.

      [ENOSPC]       The file system lacks sufficient space to create the
                     pipe.

      [ENOSR]        Could not allocate resources for both Stream heads
                     (STREAMS-based pipes only).

 SEE ALSO
      sh(1), read(2), write(2), popen(3S), streamio(7).

 STANDARDS CONFORMANCE
      pipe(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
--
Mark Bixby                      E-mail: [log in to unmask]
Coast Community College Dist.   Web: http://www.cccd.edu/~markb/
District Information Services   1370 Adams Ave, Costa Mesa, CA, USA 92626-5429
Technical Support               Voice: +1 714 438-4647
"You can tune a file system, but you can't tune a fish." - tunefs(1M)

ATOM RSS1 RSS2