User: Password:
|
|
Subscribe / Log in / New account

More fun with file descriptors

More fun with file descriptors

Posted Jun 15, 2007 19:12 UTC (Fri) by giraffedata (subscriber, #1954)
In reply to: More fun with file descriptors by vmole
Parent article: More fun with file descriptors

Any syslog that allows the user app to kill it through normal standard procedures (e.g. closing fds for a daemon) is broken. :-)

Unfortunately, this is one of those cases where you have to know something about the underlying libc implementation to avoid screwing yourself.

It's not that you have to know the underlying libc implementation. Rather, you have to know libc's requirements of its environment. You don't leave a file descriptor open because you know syslog functions use it; you leave it open because the syslog facility requires you not to mess with any file descriptor you didn't create.

There are dozens of ways a library places requirements on its environment because of resources shared among all code in the process. Some of the requirements are easily accepted, such as that a caller should not write over any memory it did not allocate (which allows the library to keep memory of its own). Sometimes the requirements are onerous, but "broken" is too strong a word for a library with inconvenient requirements. "less useful" or "dangerous" are better descriptions. Signal handlers, alarms, environment variables, stack space, terminal display space, Standard Error file contents, etc. are all controversial.


(Log in to post comments)


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds