On Thu, Sep 11, 2008 at 12:10:51AM +0200, Cedric Cellier wrote:
> Pth manual affirm that there is a distinct errno for each threads.
> The source code attemps to save it into the context structure "error"
> member.
>
> But the following program, when tried with libpth 2.0.7 on Debian
> lenny, on amd64, fails :
[...]
>
> The context sitch method guessed by configure on this system is swapcontext().
> I cannot find in libpth source code where errno is saved when using this
> method.
> Also, swapcontext manpage does not say that something is done about errno.
>
> Am I wrong or does pth_mctx_switch() miss to save errno ?
The correct question should be:
* In which cases is pth_yield allowed to touch the errno?
The manual mention the error case, but does not talk about the normal
case.
$ man 3 errno:
| A common mistake is to do
|
| if (somecall() == -1) {
| printf("somecall() failed\n");
| if (errno == ...) { ... }
| }
|
| where errno no longer needs to have the value it had upon return
from somecall(). If the value of errno should be preserved
| across a library call, it must be saved:
|
| if (somecall() == -1) {
| int errsv = errno;
| printf("somecall() failed\n");
| if (errsv == ...) { ... }
| }
Based on this, I would say that pth_yield may change the errno in the
normal case too, as its an library call.
mfg Martin Kögler
______________________________________________________________________
GNU Portable Threads (Pth) http://www.gnu.org/software/pth/
Development Site http://www.ossp.org/pkg/lib/pth/
Distribution Files ftp://ftp.gnu.org/gnu/pth/
Distribution Snapshots ftp://ftp.ossp.org/pkg/lib/pth/
User Support Mailing List [email protected]
Automated List Manager (Majordomo) [EMAIL PROTECTED]