diff options
Diffstat (limited to 'pintos-progos/tests/userprog/child-close.c')
| -rw-r--r-- | pintos-progos/tests/userprog/child-close.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pintos-progos/tests/userprog/child-close.c b/pintos-progos/tests/userprog/child-close.c new file mode 100644 index 0000000..ac948c8 --- /dev/null +++ b/pintos-progos/tests/userprog/child-close.c | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | /* Child process run by multi-child-fd test. | ||
| 2 | |||
| 3 | Attempts to close the file descriptor passed as the first | ||
| 4 | command-line argument. This is invalid, because file | ||
| 5 | descriptors are not inherited in Pintos. Two results are | ||
| 6 | allowed: either the system call should return without taking | ||
| 7 | any action, or the kernel should terminate the process with a | ||
| 8 | -1 exit code. */ | ||
| 9 | |||
| 10 | #include <ctype.h> | ||
| 11 | #include <stdio.h> | ||
| 12 | #include <stdlib.h> | ||
| 13 | #include <syscall.h> | ||
| 14 | #include "tests/lib.h" | ||
| 15 | |||
| 16 | const char *test_name = "child-close"; | ||
| 17 | |||
| 18 | int | ||
| 19 | main (int argc UNUSED, char *argv[]) | ||
| 20 | { | ||
| 21 | msg ("begin"); | ||
| 22 | if (!isdigit (*argv[1])) | ||
| 23 | fail ("bad command-line arguments"); | ||
| 24 | close (atoi (argv[1])); | ||
| 25 | msg ("end"); | ||
| 26 | |||
| 27 | return 0; | ||
| 28 | } | ||
