🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.atari16
Article #2659

Re: Fforce()

#2659
From: Landon Dyer
Date: Sat, 01 Nov 1986 18:50
42 lines
2100 bytes
In article <1639@cwruecmp.UUCP>, pm@cwruecmp.UUCP (Prabhaker Mateti) writes:
> /*
> In a program I am writing, I need to redirect input/output.  E.g., to
> redirect input from a file, I do  Fforce(0, fd), but then I can't close
> the fd and reuse that handle.  The following code demonstrates this.
> Any body has a clue as to what is wrong here??
> */
> 
> #include <osbind.h>
> 
> main()
> {
> 	int	fi, ff, fc, i;
> 
> 	for (i=0; i < 81; i++)
> 	{	fi = Fopen  ("in", 0);
> 		ff = Fforce(0, fi);
> 		fc = Fclose(fi);
> 		printf("fi ff fc %d %d %d \n", fi, ff, fc);
> 	}
> }

The problem here is the Fclose(fi) --- you can't close a handle, even
after an Fforce, because handles in GEMDOS are shared between ALL
processes.  [In theory, you could open a file, do a Pexec(), and have
the child process do I/O on the handle that the parent opened.  In
practice, this is a bad practice....]

Negative handles correspond (kind of) to BIOS devices, -1 is CON:, -2
is AUX:, and so on.  Handles from 0 to 5 are "standard" handles, and
are inherited by the child on a Pexec().  Handles 6 and up always
refer to files.  Standard handles are a kind of indirection; they
"point" to a character device (handle < 0) or a file handle (> 5).

-- 

-Landon Dyer, Atari Corp.		        {sun,lll-lcc,imagen}!atari!dyer

/-----------------------------------------------\
| The views represented here do not necessarily | "If Business is War, then
| reflect those of Atari Corp., or even my own. |  I'm a Prisoner of Business!"
\-----------------------------------------------/
Technical Details
Message-ID: <449@atari.UUcp>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!nike!sri-spam!sri-unix!hplabs!pyramid!decwrl!sun!imagen!atari!dyer
References: <1639@cwruecmp.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!nike!sri-spam!sri-unix!hplabs!pyramid!decwrl!sun!imagen!atari!dyer
From: dyer@atari.UUcp (Landon Dyer)
Newsgroups: net.micro.atari16
Subject: Re: Fforce()
Message-ID: <449@atari.UUcp>
Date: Sat, 1-Nov-86 13:50:57 EST
Article-I.D.: atari.449
Posted: Sat Nov  1 13:50:57 1986
Date-Received: Tue, 4-Nov-86 01:05:26 EST
References: <1639@cwruecmp.UUCP>
Organization: Atari Corp., Sunnyvale CA
Lines: 42