Write both in std output and in a file ?

Donn Cave donn at u.washington.edu
Thu Jan 17 20:30:53 EST 2002


Quoth pj at sgi.com (Paul Jackson):
| Alex replied to Chris:
||> > Actually C does the auto-close also (at least on all platforms I've
||> > worked on).
||> 
||> I recall reasonably-early C compilers for DOS that didn't auto-close.
|
| I really doubt that C is doing any auto close.  On the other
| hand, I really doubt that I've caught Alex Martelli in such a
| misstatement, so I must be confused <grin>.
|
| Perhaps you mean the operating system closes files on process
| exit (where one could claim that early DOS wasn't an operating
| system ;).

But C has its own FILE, with state that resides within process memory.
Particularly, a buffer.  The OS can't manage that state, because it's
process-internal.  The C library does indeed close its open FILEs, on
exit() or return from main().  You can avoid this with _exit() (in
Python, posix._exit()), say in a fork that shouldn't flush buffers
inherited from its parent.  Python's file object is a C FILE.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list