This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Thread-, Signal- and Cancellation-safety documentation


On Jun  2, 2013, Rich Felker <dalias@aerifal.cx> wrote:

> you can use them meaningfully in a multithreaded program as long as
> it's clear that you're not stepping on other modules' data.

That constraint you put is quite convenient.  Why don't you apply it to
chdir too?  As in, if other threads/modules don't use files at all, or
only use full pathnames, or only use *at() calls, *then* you can use
chdir meaningfully and safely in that one thread.  Or, if threads in the
process set a convention to acquire a conventional lock to call chdir
and then whatever other filesystem operation they wish using relative
pathnames before releasing the lock, that's another form of âus[ing]
meaningfully as long as it's clear...â

I call that a distinction without a difference:

> Assuming you use libraries that are "black boxes" (i.e. you don't have
> any guarantees about their implementations, only their interfaces)
> chdir can NEVER be called safely

Just like the other calls we mentioned before, when used in situations
that assume and require some form of exclusivity that the black box
library might break.  Or can you somehow assure the black box library
won't call creat or rename or whatever in the dir that was supposed to
be exclusively used for something else, but can't equally assure it
won't call chdir?!?

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]