HP3000-L Archives

March 2000, 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:
Johan Harmsen <[log in to unmask]>
Reply To:
Johan Harmsen <[log in to unmask]>
Date:
Fri, 10 Mar 2000 09:05:46 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (68 lines)
Hi,

Maybe somebody can give some insights on the problem described below. I checked HP's support database but couldn't find any reference to this or similar problems. So I think I do something that's not allowed, but don't have a clue what.

I have the following C program, compiled in the Posix shell (Ok, the original program had more functionality, but this clearly shows the problem)

# include   <stdio.h>
# include   <fcntl.h>
main(int argc, char *argv[])
{
    int fnr;

    fnr = open(argv[1], O_RDONLY);
    printf ("%s : %d\n", argv[1], fnr);
    getchar();
}

Compile with the command : c89 prog.c -o /SYS/TMP/MYPROG

When I run this program from the shell I get the following result :

shell/iX> /SYS/TMP/MYPROG /SYS/PUB/CICAT
/SYS/PUB/CICAT : 11

When I look at the files opened by the process, using a program that calls some AIF functions to get the open files per process I get, apart from $STDIN, $STDLIST, STDERR, and some references to HFS directories, the following :

8: /SYS/HPBIN/SH
9: /etc/profile
10: /SYS/TMP/MYPROG
11: /SYS/PUB/CICAT

So far so good. But now I run the program from the 'normal' CI prompt, and I get :

:run MYPROG.TMP.SYS;info='/SYS/PUB/CICAT'
/SYS/PUB/CICAT : 10

That could be right of course but when I look at the open files now I get the following surprising result

:listfile cicat.pub.sys,9
********************
FILE: CICAT.PUB.SYS
2 Accessors(O:2,P:2,L:0,W:0,R:2),Share
#S145 JOHAN,MANAGER.SYS P:2,L:0,W:0,R:2 REM : 193.78.7.115
#P97 (MYPROG.TMP.SYS)
ACCESS: R-excl REC#: 0 FNUM: 10
LOCKS: none
#P97 (MYPROG.TMP.SYS)
ACCESS: R-excl REC#: 0 FNUM: 9
LOCKS: none

And my program looking for open files shows similar information:

8: /SYS/TMP/MYPROG
9: /SYS/PUB/CICAT
10: /SYS/PUB/CICAT

The file is opened twice !. CICAT is just used as an example, the same problem occurs for any (readable) file.
It appears that 10 is a completely valid handle, I can do anything I want with it, but my program obviously has no knowledge about file handle 9, so the file remains open after I think I close it, when closing handle 10.
It appears that this problem only appears if the first available file handle is less than 10, if the file handle returned is larger the file is opened only once.
I tried to debug the program, but it seems that the debugger loads SL.PUB.SYS, thus eliminating the problem.
The only solution I found so far is doing calls to 'dup' after the programs starts, until this function returns a value greater than 10, but I would rather find a solution for the problem then this workaround.

Any insights will be greatly appreciated, thanks in advance !

Holland House B.V.

Johan Harmsen

ATOM RSS1 RSS2