[Top][All Lists]

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

Re: [Chicken-hackers] shouldn't file-close dispatch an interrupt on EINT

From: Peter Bex
Subject: Re: [Chicken-hackers] shouldn't file-close dispatch an interrupt on EINTR?
Date: Sun, 27 Mar 2016 17:22:57 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Mar 22, 2016 at 10:45:09PM +0100, Jörg F. Wittenberger wrote:
> Hi all,
> after literally years of wondering why I'm seeing lost file descriptors
> I _guess_ I spotted the reason.  file-close raises an error when
> close(2) returns a negative value.  IMHO it should look like this (not
> yet tested):
> (define file-close
>   (lambda (fd)
>     (##sys#check-exact fd 'file-close)
>     (if (fx< (##core#inline "C_close" fd) 0)
>       (select _errno
>        ((_eintr) (##sys#dispatch-interrupt (lambda () (file-close fd))))
>        (else (posix-error #:file-error 'file-close "cannot close file" fd)))
> ) ) )

This is why I dislike the posix module so much, it's so low-level that
it doesn't even bother to abstract away these things.  It's C with
parentheses, except in some cases where the abstraction is so high that
it's even unlike POSIX (for example in the "process" procedures).

I don't know if that's by design (because it's *meant* to be low-level),
or just an oversight.

Anyway, I think you're right and it should keep retrying.  See attached


Attachment: 0001-Automatically-retry-file-close-on-_eintr.chicken-5.patch
Description: Text Data

Attachment: 0001-Automatically-retry-file-close-on-_eintr.master.patch
Description: Text Data

Attachment: signature.asc
Description: Digital signature

reply via email to

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