HP3000-L Archives

April 2010, Week 3

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:
"Fairchild, Craig D" <[log in to unmask]>
Reply To:
Fairchild, Craig D
Date:
Wed, 21 Apr 2010 22:45:50 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (22 lines)
Brian writes...
> So I thought by putting the subsequent calls to fopen in its own program that may solve the problem.
> Well, it kind of solves the problem except it is giving me conficting file numbers between mainline #1 & #2

There's no such thing as conflicting file numbers between two different processes. A file number returned from an [HP[F[OPEN]]] call is meaningful only within the context of the process that performed the open. Comparing file numbers between two different processes (with the exception of a forked process) is meaningless. It only has meaning for a forked process because the child process is an exact replica of the parent process, including the set of files that are opened.

An example of this is the reserved file numbers 0 - 2 ($STDIN, $STDLIST, $STDERR). Every process (by default) has a file number 0 - its $STDIN - which will be a different file or device for processes in different job/session trees.

Just a little side info... File numbers 0-7 are reserved for system use. File 8 is the first "unreserved" file number. You'll never get it though. After a process is created the loader is called to load the program which is going to be executed in the process. The loader needs to minimally open the program file (which will get file number 8), and then any libraries that are necessary (a variable number depending on how the executable was linked). Run a program with the ;debug option? The debugger may open files too, depending on the actions taken. So by the point that the first instruction of your program is executed, the first file number available will be minimally 9, or higher, depending on the program, how it was built, and how it was executed.

File numbers should ALWAYS be treated as opaque handles to the file objects they refer to. A program should NEVER assume any hardcoded value for a file number with the exception of the reserved files 0, 1 and 2. (And even then...)

>
> I have been messing with this problem for over two weeks now and I
> cannot figure out why the subsequent fopen's are failing. It has me
> beat.

Perhaps one place to start is to identify the error that is being returned? HPFOPEN returns the status value to you. With FOPEN you need to call FCHECK. With open() you need to check the global variable errno.

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

ATOM RSS1 RSS2