HP3000-L Archives

December 2001, Week 2

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:
Mark Bixby <[log in to unmask]>
Date:
Tue, 11 Dec 2001 14:05:23 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (42 lines)
If this were a POSIX program, you could use the dup2() function to do it:

http://docs.hp.com/mpeix/onlinedocs/36430-90007/00/00/34-con.html

The above documentation is pretty awful; dup2(fd1,fd2) says take open file
descriptor fd1 and duplicate it so that you could also access the same file via
file descriptor fd2.  If fd2 was already opened as something else, it would be
closed first.

It's pretty common to see POSIX programs do things like:

fd = open("/some/disk/file", O_RDONLY);
dup2(fd, 0);

File descriptor 0 is stdin; fd 1 is stdout, and fd 2 is stderr.

File descriptors and MPE file numbers are both 32-bit integers, but they are
not equal values.  There are conversion macros for converting file descriptors
to file numbers and vice versa.  See /usr/include/fcntl.h for details.

I do not know what would happen if you called dup2() from a non-POSIX program
using Pascal.  If this rips a hole in the fabric of the space/time continuum,
don't blame me!  ;-)

- Mark B.

Born, Ken wrote:

> Greetings,
> I have a program that passes in an info string into a PASCAL program and now
> want to be able to take that info string, parse it,
> and issue a command or file equate that will assign my STDIN and then
> perform my READX.  Currently, my STDIN is defined in my SENDMAIL Alias file.
> Any ideas ?  Thanks...

--
[log in to unmask]
Remainder of .sig suppressed to conserve scarce California electrons...

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2