chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] difference between ##sys#error and posix-error?


From: Alaric Snell-Pym
Subject: Re: [Chicken-users] difference between ##sys#error and posix-error?
Date: Thu, 29 Sep 2011 12:15:19 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/29/2011 08:36 AM, Christian Kellermann wrote:
> Hi Alan!
>
> * Alan Post <address@hidden> [110929 05:51]:
>> Looking at posixunix.scm, I find that some error messages are
>> produced with ##sys#error, and others with posix-error.  What
>> distinguishes these two routines?  Why would I use one but not
>> the other?
>
> (define posix-error
>   (let ([strerror (foreign-lambda c-string "strerror" int)]
>       [string-append string-append] )
>     (lambda (type loc msg . args)
>       (let ([rn (##sys#update-errno)])
>       (apply ##sys#signal-hook type loc (string-append msg " - " (strerror 
> rn)) args) ) ) ) )


Ooof, is that correct? IIRC, strerror isn't thread safe. We may not be
using POSIX threads, but might Chicken not schedule a new thread between
strerror and string-append, which might itself call strerror and thus
produce an invalid error message? I'm not sure at what points the
scheduler is actually able to preempt.

The solution, if that is a potential problem, is strerror_r, where you
pass in your own string buffer.

ABS

- --
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6EU0cACgkQRgz/WHNxCGoKwwCgh/PKkHikbGLulucz0Y9YwsvP
HUEAniTO3Vq8zcCfYbbgghTcMm24khx7
=ZjGh
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]