Unix deficiencies/problems

Jeffrey Kegler jeffrey at algor2.UUCP
Fri May 12 00:41:30 AEST 1989


In article <2656 at mentor.cc.purdue.edu>, mjs at mentor.cc.purdue.edu (Mike Spitzer) writes:
> 	application <input >logfile 2>errs 3<db1 4<db2 5>rep1 6>rep2
> [...]
>

In a previous followup to this message I asserted that this syntax is highly
dependent on the order of open() calls in the application.  That turns out
to wrong as a few people have pointed out to me by Email.

The rules, as I now understand them, are

1) The shell opens file descriptors 0, 1 and 2.
2) It also opens any descriptors explicitly redirected on the command line
(3 through 6, in the above).
3) It also opens any descriptors explicitly redirected in exec commands.
4) The application's open() calls return the remaining file descriptors, lowest
first.

This actually forms a fairly reasonable replacement to logical file names.

Remaining problem:  Any file descriptors whose redirection is forgotten, are
returned in response to the application's open calls.  This could cause wierd
open() order dependent behavior.  The logging data could wind up being written
into the database, for example.
-- 

Jeffrey Kegler, President, Algorists,
jeffrey at algor2.UU.NET or uunet!algor2!jeffrey
1762 Wainwright DR, Reston VA 22090



More information about the Comp.unix.questions mailing list