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: Christian Kellermann
Subject: Re: [Chicken-users] difference between ##sys#error and posix-error?
Date: Thu, 29 Sep 2011 13:24:01 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

* Alaric Snell-Pym <address@hidden> [110929 13:18]:
> -----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.

posix unit declares disable-interrupts which does:

Disable timer-interrupts checks in the compiled program. Threads
can not be preempted in main- or library-units that contain this
declaration.

Does this help your understanding? Should be safe IMHO.

Kind regards,

Christian

-- 
Who can (make) the muddy water (clear)? Let it be still, and it will
gradually become clear. Who can secure the condition of rest? Let
movement go on, and the condition of rest will gradually arise.
 -- Lao Tse. 



reply via email to

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