Recent change to Xprint/attributes.c breaks build

Felix Schulte felix.schulte at gmail.com
Tue May 3 14:35:22 PDT 2005


On 5/3/05, Glynn Clements <glynn at gclements.plus.com> wrote:
> 
> Adam Jackson wrote:
> 
> > > > pread() is Unix98, not POSIX.
> > > >
> > > > It's perfectly possible to emulate pread:
> > > >
> > > > off_t saved = lseek(fd, 0, SEEK_CUR);
> > > > lseek(fd, offset, SEEK_SET);
> > > > read(fd, buf, count);
> > > > lseek(fd, saved, SEEK_SET);
> > > >
> > > > Granted it's a few more system calls and it's not reentrant, but it
> > > > works.  I would suggest that we add this to os-support/, since it's easy
> > > > to emulate and part of a relatively well-adopted standard.
> > >
> > > And to make it re-entrant-ish you could add a few more calls around the
> > > above code to lock byte 0 of the file while you're doing the pread()
> > > to ensure that another process (not thread) doesn't come behind you
> > > and change the offset.
> >
> > I thought fd state was per-process and not global.
> 
> No; if a descriptor is duplicated, either explicitly by dup() etc or
> implicitly by fork(), all copies share the same offset.
> 
> The only way to get multiple descriptors for a given file which don't
> share offsets is to open() the file multiple times.
Does POSIX provide a variant of open() which takes a fd as argument?
The code of bug #790 uses tmpfile() which unlinks the file before
returning the handle.

-- 
      _        Felix Schulte
    _|_|_     mailto:felix.schulte at gmail.com
    (0 0)        
ooO--(_)--Ooo



More information about the xorg mailing list