This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Thread-, Signal- and Cancellation-safety documentation
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Rich Felker <dalias at aerifal dot cx>
- Cc: Florian Weimer <fweimer at redhat dot com>, Torvald Riegel <triegel at redhat dot com>, KOSAKI Motohiro <kosaki dot motohiro at gmail dot com>, libc-alpha <libc-alpha at sourceware dot org>
- Date: Sun, 02 Jun 2013 14:20:37 -0300
- Subject: Re: Thread-, Signal- and Cancellation-safety documentation
- References: <20130402134325 dot GO20323 at brightrain dot aerifal dot cx> <CAHGf_=q=2sM0C5kLazsVWiRfRvO0NX-sDRX2-SfoJkkCix9vzQ at mail dot gmail dot com> <1368788825 dot 3054 dot 3182 dot camel at triegel dot csb> <ora9nrh1cz dot fsf at livre dot home> <51A328F0 dot 5020003 at redhat dot com> <ora9ncqlg4 dot fsf at livre dot home> <51A86363 dot 2000900 at redhat dot com> <orip1yq3ek dot fsf at livre dot home> <20130601025934 dot GJ20323 at brightrain dot aerifal dot cx> <or61xxi33w dot fsf at livre dot home> <20130602142028 dot GL20323 at brightrain dot aerifal dot cx>
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