PKUOS - Pintos
Pintos source browser for PKU Operating System course
child-close.c
Go to the documentation of this file.
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
16const char *test_name = "child-close";
17
18int
19main (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}
int main(int argc UNUSED, char *argv[])
Definition: child-close.c:19
const char * test_name
Child process run by multi-child-fd test.
Definition: child-close.c:16
static int isdigit(int c)
Definition: ctype.h:7
#define UNUSED
GCC lets us add "attributes" to functions, function parameters, etc.
Definition: debug.h:7
int atoi(const char *s)
Converts a string representation of a signed decimal integer in S into an ‘int’, which is returned.
Definition: stdlib.c:10
void close(int fd)
Definition: syscall.c:139
void fail(const char *format,...)
Definition: lib.c:40
void msg(const char *format,...)
Definition: lib.c:28