Re: __attribute__((warn_unused_result)) for NetBSD?
der Mouse <[email protected]> Mon, 29 Sep 2008 00:20:15 -0400 (EDT)
| Newsgroups | gmane.os.netbsd.devel.general |
|---|---|
| Message-ID | <[email protected]> |
>>> Recall that a signal handler, being an interrupt, is roughly >>> speaking not allowed to do anything other than assign a value of >>> type sig_atomic_t. >> Not quite. Rather, if it does do any other thing, it is off in >> implementation-dependent weeds. > Yes and no - despite the dire wording in the standards, the real > issue is that signals are essentially interrupts, so you might end up > reentering nonreentrant code. Right. But what code is non-reentrant is implementation-dependent. I think I could, to pick a slightly contrived example, build a stdio which could be safely used within signal handlers, under relatively liberal assumptions about how signals are implemented (stricter than POSIX's, of course, but more liberal than any real Unix I know of - and, of course, stdio, being part of the implementation, can know details of signal delivery that are not promisd by POSIX). > Because of the way signals are (and have to be) implemented, making > system calls is ~always going to be safe. Calling libc functions > like fopen, though, really is a bad idea. Except there is no reason except implementation tradition and convenience for fopen to be a library function rather than a syscall (or, more precisely, for it to be a non-reentrant library function, syscalls being just one class of reentrant library functions). /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTML [email protected] / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B