From: Ben Pfaff Date: Wed, 5 Apr 2006 19:43:13 +0000 (+0000) Subject: Clarify how termination treats file descriptors. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eee676b2d1e18dedb2fe31615473d321b5b36426;p=pintos-anon Clarify how termination treats file descriptors. Thanks to Nathan Marz for the question. --- diff --git a/doc/userprog.texi b/doc/userprog.texi index d5eee6d..5918612 100644 --- a/doc/userprog.texi +++ b/doc/userprog.texi @@ -656,8 +656,7 @@ Consider implementing this function in terms of @func{filesys_remove}. @deftypefn {System Call} int open (const char *@var{file}) Opens the file called @var{file}. Returns a nonnegative integer handle called a ``file descriptor'' (fd), or -1 if the file could not be -opened. All open files associated with a process should be closed -when the process exits or is terminated. +opened. File descriptors numbered 0 and 1 are reserved for the console: fd 0 is standard input (@code{stdin}), fd 1 is standard output @@ -732,7 +731,9 @@ Consider implementing this function in terms of @func{file_tell}. @end deftypefn @deftypefn {System Call} void close (int @var{fd}) -Closes file descriptor @var{fd}. +Closes file descriptor @var{fd}. +Exiting or terminating a process implicitly closes all its open file +descriptors, as if by calling this function for each one. Consider implementing this function in terms of @func{file_close}. @end deftypefn