From: Moritz Heidkamp <[email protected]> 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 _______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
