Re: perror sets errno to "Illegal Seek"
From: Joe Pfeiffer (pfeiffer_at_cs.nmsu.edu)
Date: 12/16/04
- Next message: Otto Wyss: "Re: Backtrace"
- Previous message: gipsy boy: "Re: perror sets errno to "Illegal Seek""
- In reply to: gipsy boy: "Re: perror sets errno to "Illegal Seek""
- Next in thread: Kasper Dupont: "Re: perror sets errno to "Illegal Seek""
- Reply: Kasper Dupont: "Re: perror sets errno to "Illegal Seek""
- Reply: gipsy boy: "Re: perror sets errno to "Illegal Seek""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 16 Dec 2004 09:40:47 -0700
gipsy boy <x@x.pi> writes:
> Ulrich Eckhardt wrote:
> > gipsy boy wrote:
> >
> >> It was just a problem with another thread that set errno.. Errno.h
> >> and threads really don't seem to go well together?..
> > I was under the impression that 'errno' has been in thread-specific
> > storage
> > for ages... or?
>
> I have the most recent glibc, and it doesn't seem to do that..
> I mean, if I have
>
>
> perror("test1");
> perror("test2");
>
> While another thread is running, that sets errno to a certain value, I
> can get :
> test1 : Success
> test2 : Illegal Seek
Doesn't this verify that errno is thread-safe? It gets set to a value
in a thread, only that thread sees the new value?
> Maybe perror(".."); and the whole "int errno;" are deprecated though,
> and that's my mistake?
> It's just a tiny C part for a C++ project (where I use exceptions), so
> it doesn't matter that much..but what's the right way to use errors
> and threads then, in C?
errno and perror are the right way. My newsfeed doesn't seem to
always get the whole thread: it's been established that the behavior
you're seeing is perfectly normal, and that you can save errno and
restore it before doing your second perror call (though why you're
wanting to look at its value after you've reported the error is
something of a mystery to me). So why are you now asking if errno and
perror are deprecated?
-- Joseph J. Pfeiffer, Jr., Ph.D. Phone -- (505) 646-1605 Department of Computer Science FAX -- (505) 646-1002 New Mexico State University http://www.cs.nmsu.edu/~pfeiffer
- Next message: Otto Wyss: "Re: Backtrace"
- Previous message: gipsy boy: "Re: perror sets errno to "Illegal Seek""
- In reply to: gipsy boy: "Re: perror sets errno to "Illegal Seek""
- Next in thread: Kasper Dupont: "Re: perror sets errno to "Illegal Seek""
- Reply: Kasper Dupont: "Re: perror sets errno to "Illegal Seek""
- Reply: gipsy boy: "Re: perror sets errno to "Illegal Seek""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|