Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!elroy.jpl.nasa.gov!ncar!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: freopen(), access() Message-ID: <14944@smoke.brl.mil> Date: 23 Jan 91 23:10:49 GMT References: Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 28 In article yang@nff.ncl.omron.co.jp (YANG Liqun) writes: >In arcticle <15715hh2x@vax5.cit.cornell.edu> writes: >>Could someone please explain the functions freopen() and access()? My reaction was, somebody should tell this guy that if he expects to deal with UNIX source code he should go to his local technical bookstore and buy a copy of some UNIX Programmer Reference Manual. >As far I know, [access] is written in assembler in System V. No, while all the system-call hooks in the C library are tiny assembly- language modules that merely cause a trap with the proper subcode, the actual implementation of system calls in the UNIX kernel originates as C source code. I suspect that whatever code is using access() already has a bug, since access() rarely does what any sensible application would want it to do. (This is a design deficiency in the semantics for access().) >For freopen(), you can easily rewrite it in C. But only if you know enough about the specific implementation of stdio for the system in question. The main constraint is that the same FILE structure must be used for the newly opened file. Odds are good that the application in question can be readily changed to use fclose()/fopen() rather than relying on freopen(). That would be preferable to trying to implement one's own freopen().