00001 /* Opens a file and then runs a subprocess that tries to close 00002 the file. (Pintos does not have inheritance of file handles, 00003 so this must fail.) The parent process then attempts to use 00004 the file handle, which must succeed. */ 00005 00006 #include <stdio.h> 00007 #include <syscall.h> 00008 #include "tests/userprog/sample.inc" 00009 #include "tests/lib.h" 00010 #include "tests/main.h" 00011 00012 void 00013 test_main (void) 00014 { 00015 char child_cmd[128]; 00016 int handle; 00017 00018 CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 00019 00020 snprintf (child_cmd, sizeof child_cmd, "child-close %d", handle); 00021 00022 msg ("wait(exec()) = %d", wait (exec (child_cmd))); 00023 00024 check_file_handle (handle, "sample.txt", sample, sizeof sample - 1); 00025 }