a question on open() and lseek()
Edward C. Bennett
edward at ukecc.UUCP
Sun Apr 27 07:54:09 AEST 1986
In article <1968 at ism780c.UUCP>, tim at ism780c.UUCP (Tim Smith) writes:
> In article <691 at edison.UUCP> jso at edison.UUCP (John Owens) writes:
> >> Is there any reason to use the sequence:
> >> f = open( file, O_WRONLY );
> >> lseek( f, 0, L_XTND );
> >> instead of the single call:
> >> f = open( file, O_WRONLY | O_APPEND );
> >
> >Because many versions of UNIX do not support the O_APPEND flag; it's
> >a fairly recent innovation. All versions since v7 (at least that I'm
> >aware of) should support the open/lseek method.
>
> How about doing both? Unixes that do not recognize O_APPEND will probably
> ignore it, and unixes that do will ignore the lseek.
>
#ifdef O_APPEND
f = open( file, O_WRONLY | O_APPEND );
#else
f = open( file, O_WRONLY );
lseek( f, 0, L_XTND );
#endif
--
Edward C. Bennett
UUCP: ihnp4!cbosgd!ukma!ukecc!edward
Kentucky: The state that is being dragged, kicking and screaming,
into the 20th century.
"Goodnight M.A."
More information about the Comp.unix.wizards
mailing list