ac948c8efe6978e98960fceda85218b84a3c3415
[pintos-anon] / src / tests / userprog / child-close.c
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 }