Extend File Descriptor (Extra)
Make your pintos to support closing of stdin, stdout and dup2 system call in linux
The closing the fd of
stdout is forbidden in current
implementation of pintos. In this extra point requirements, you first allow user
stdout as same as the linux. That is, the process should
never read the inputs if you close
stdin, and the process should never print
out anything if you close
Next, implement the
dup2 system call.
int dup2(int oldfd, int newfd);
dup2()system call creates a copy of the file descriptor
oldfdwith the file descriptor number specified in
newfd, and returns
newfdon success. If the file descriptor
newfdwas previously open, it is silently closed before being reused.
Note the following points:
oldfdis not a valid file descriptor, then the call fails (returns
newfdis not closed.
oldfdis a valid file descriptor, and
newfdhas the same value as
dup2()does nothing, and returns
After a successful return from this system call, the old and new file descriptors may be used interchangeably. Although they are different file descriptors, they refer to the same open file description and thus share file offset and status flags; for example, if the file offset is modified by using
seekon one of the descriptors, the offset is also changed for the other.
duped file descriptors must preserve their semantic after the
YOU SHOULD PASS ALL TESTCASES FOR EXTRA TO GET THE CREDIT. TAKE ALL OR NOTHING.