The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: rudi.j.blom@gmail.com (Rudi Blom)
Subject: [TUHS] EOF on pipes?
Date: Mon, 26 Feb 2018 23:03:55 +0700	[thread overview]
Message-ID: <CAMYpm84wHrGBmqTbptgJK6CJXhA1SBkcNBWVVqZNi3Ld+4RcvQ@mail.gmail.com> (raw)

From a piece of code I have in some SCO UNIX 3.2V4.2 source. SCO
doesn't have pipes, but you can simulate them.

	int fd[2]
	int rc;
	struct strfdinsert ins;
	queue_t *pointer = (queue_t *)NULL;

	rc = -1;
	/*
	 * First open the stream clone device "/dev/spx" twice,
	 * obtaining the two file descriptors.
	 */
	if ( (fd[0] = open(SPX_DEVICE, O_RDWR)) < 0)
	{
		gen_trace(gtr_flag, "-gen_pipe(): -open(fd[0]): %s\n", strerror(errno));
		break;
	}
	if ( (fd[1] = open(SPX_DEVICE, O_RDWR)) < 0)
	{
		gen_trace(gtr_flag, ">gen_pipe(): -open(fd[1]): %s\n", strerror(errno));
		close(fd[0]);
		break;
	}

	/*
	 * Now link these two streams together with an
	 * I_FDINSERT ioctl.
	 */
	ins.ctlbuf.buf     = (char *) &pointer; /* no ctl info, just the ptr */
	ins.ctlbuf.maxlen  = sizeof(queue_t *);
	ins.ctlbuf.len     = sizeof(queue_t *);
	ins.databuf.buf    = (char *) 0;        /* no data to send */
	ins.databuf.len    = -1; /* magic: must be -1, not 0, for stream pipe */
	ins.databuf.maxlen = 0;
	ins.fildes = fd[1];     /* the fd to connect with fd[0] */
	ins.flags  = 0;         /* nonpriority message */
	ins.offset = 0;         /* offset of pointer in control buffer */
	if (ioctl(fd[0], I_FDINSERT, (char * ) &ins) < 0)
	{
		gen_trace(gtr_flag, ">gen_pipe(): -ioctl(I_FDINSERT): %s\n", strerror(errno));
		close(fd[0]);
		close(fd[1]);
		break;
	}


         reply	other threads:[~2018-02-26 16:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24 21:33 Dave Horsfall
2018-02-24 23:13 ` Ron Natalie
2018-02-24 23:42   ` Bakul Shah
2018-02-24 23:46     ` Nelson H. F. Beebe
2018-02-24 23:46     ` Jon Steinhart
2018-02-26 16:03 ` Rudi Blom [this message]
2018-02-26 16:58   ` Ian Zimmerman
2018-02-26 17:19     ` Larry McVoy
2018-02-25  0:53 Norman Wilson
2018-02-25 16:29 ` Paul Winalski
2018-02-25 22:25 ` Lyndon Nerenberg
2018-02-25 23:18   ` Bakul Shah
2018-02-26  2:39   ` Grant Taylor
2018-02-25 13:07 Doug McIlroy
2018-02-25 13:16 ` George Michaelson
2018-02-25 13:56   ` arnold
2018-02-27  5:04 Rudi Blom
2018-02-27  5:48 ` Dave Horsfall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMYpm84wHrGBmqTbptgJK6CJXhA1SBkcNBWVVqZNi3Ld+4RcvQ@mail.gmail.com \
    --to=rudi.j.blom@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).