summaryrefslogtreecommitdiffstats
path: root/src/tests/userprog/child-close.c
diff options
context:
space:
mode:
authorFelipe Boeira <felipe.boeira@liu.se>2019-01-08 18:39:03 +0100
committerFelipe Boeira <felipe.boeira@liu.se>2019-01-08 18:39:03 +0100
commitd4522b8e9854178473adcea0fbb84f23f6e744bd (patch)
treefbcf620617c5023154eba3f965b3a982daa64a47 /src/tests/userprog/child-close.c
downloadpintos-d4522b8e9854178473adcea0fbb84f23f6e744bd.tar.gz
Initial commit
Diffstat (limited to 'src/tests/userprog/child-close.c')
-rw-r--r--src/tests/userprog/child-close.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tests/userprog/child-close.c b/src/tests/userprog/child-close.c
new file mode 100644
index 0000000..ac948c8
--- /dev/null
+++ b/src/tests/userprog/child-close.c
@@ -0,0 +1,28 @@
+/* Child process run by multi-child-fd test.
+
+ Attempts to close the file descriptor passed as the first
+ command-line argument. This is invalid, because file
+ descriptors are not inherited in Pintos. Two results are
+ allowed: either the system call should return without taking
+ any action, or the kernel should terminate the process with a
+ -1 exit code. */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <syscall.h>
+#include "tests/lib.h"
+
+const char *test_name = "child-close";
+
+int
+main (int argc UNUSED, char *argv[])
+{
+ msg ("begin");
+ if (!isdigit (*argv[1]))
+ fail ("bad command-line arguments");
+ close (atoi (argv[1]));
+ msg ("end");
+
+ return 0;
+}