chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Pipe and thread problem


From: Felix
Subject: Re: [Chicken-users] Pipe and thread problem
Date: Thu, 25 Oct 2012 04:12:50 -0400 (EDT)

From: Moritz Heidkamp <address@hidden>
Subject: Re: [Chicken-users] Pipe and thread problem
Date: Wed, 24 Oct 2012 23:10:20 +0200

> Hey Chickeneers,
> 
> out of curiosity I implemented (probably horribly inefficitent)
> thread-aware replacements for open-input-file* and open-output-file*
> (see below). While implementing them I came across something that I
> didn't quite understand: file-read and file-write raise errors whenever
> the underlying syscall returns -1. However, in this case I want to
> handle some error situations (i.e. EINTR, EAGAIN and EWOULDBLOCK). The
> only way I could find to do this is by dispatching on (errno) in the
> excpetion handler. However it looks like (errno) is not thread-safe so
> it might actually return a different value when my handler is run. Is
> this observation correct? Perhaps we should mention this in errno's
> documentation? Also, to make it possible to handle these errors I
> suggest to add the respective errno to the condition object. This would
> be thread-safe as the posix unit declares disable-interrupts. Thoughts?

No, "errno" is not thread-safe. Posix-related errors (see "posix-error"
in "posix-common.scm") get attached the error-string (obtained via
strerror(3)), also adding errno would be fine, I'd say.

I'm quite sure "##sys#custom-input-port" and
"##sys#custom-output-port" in "posixunix.scm" are alreay doing what
you want, and much more efficiently.


cheers,
felix



reply via email to

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