Library /sys$common/syshlp/helplib.hlb  —  CRTL  decc$write_eof_to_mbx, Example
        /*      decc$write_eof_to_mbx_example.c         */

        #include <errno.h>
        #include <stdio.h>
        #include <string.h>

        #include <fcntl.h>
        #include <unistd.h>
        #include <unixio.h>

        #include <descrip.h>
        #include <ssdef.h>
        #include <starlet.h>

        int decc$write_eof_to_mbx( int );

        main()
        {
          int status, nbytes, failed = 0;
          int fd, fd2[2];
          short int channel;
          $DESCRIPTOR(mbxname_dsc, "TEST_MBX");
          char c;

          /* first try a mailbox created by SYS$CREMBX        */

        status = sys$crembx(0, &channel, 0, 0, 0, 0, &mbxname_dsc, 0, 0);
        if ( status != SS$_NORMAL ) {
             printf("sys$crembx failed: %s\n",strerror(EVMSERR, status));
             failed = 1;
          }

         if ( (fd = open(mbxname_dsc.dsc$a_pointer, O_RDWR, 0)) == -1) {
              perror("? open mailbox");
              failed = 1;
          }

          if ( decc$write_eof_to_mbx(fd) == -1 ) {
              perror("?  decc$write_eof_to_mbx to mailbox");
              failed = 1;
          }

          if ( (nbytes = read(fd, &c, 1)) != 0 || errno != 0 ) {
              perror("? read mailbox");
              printf("? nbytes = %d\n", nbytes);
              failed = 1;
          }

          if ( close(fd) == -1 ) {
              perror("? close mailbox");
              failed = 1;
          }

          /* Now do the same thing with a pipe                */

          errno = 0;           /* Clear errno for consistency */

          if ( pipe(fd2) == -1 ) {
              perror("? opening pipe");
              failed = 1;
          }

          if ( decc$write_eof_to_mbx(fd2[1]) == -1 ) {
              perror("? decc$write_eof_to_mbx to pipe");
              failed = 1;
          }

          if ( (nbytes = read(fd2[0], &c, 1)) != 0 || errno != 0 ) {
              perror("? read pipe");
              printf("? nbytes = %d\n", nbytes);
              failed = 1;
          }

          /* Close both file descriptors involved with the pipe    */

          if ( close(fd2[0]) == -1 ) {
              perror("close(fd2[0])");
              failed = 1;
          }

          if ( close(fd2[1]) == -1 ) {
              perror("close(fd2[1])");
              failed = 1;
          }

          if ( failed )
              puts("?Example program failed");
          else
              puts("Example ran to completion");
        }

      This example program produces the following result:

        Example ran to completion
Close Help