unix test 2 review Flashcards
The ____ contains all the information about the file: the file type, the file’s access permission bits, the size of the file, pointers to the file’s data blocks, and so on.
i- node
By convention, all shells in Unix open ___ file descriptors whenever a new program is run.
3
A process may do \_\_\_ with the signal ignore the signal let the default action occur provide a function to handle the signal all of the above
All of the above
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.
if (pid=fork()) {fork();}
if (pid=fork()) {fork();}
if (pid=fork()) {fork();}
27
A ___ has only one thread of control - one set of machine instructions executing at a time.
process
After fork, the differences between the parent and child are: The return values from fork The process IDs The different parent process IDs Correct All of the above
All of the above
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.
if (pid=fork() && pid2 = fork()) {fork();}
if (pid=fork() && pid2 = fork()) {fork();}
if (pid=fork() && pid2 = fork()) {fork();}
64
A file ___ is normally small non-negative integer that the kernel uses to identify the files accessed by a process.
descriptor
Given fork program as shown below, what would be the total number of processes at the end including the process running this program initially.
for (i=1; i
4
By convention, UNIX System shells associate the file descriptor __ with the standard input of a process.
0
This instruction ___ takes two (file descriptor) arguments, to duplicate the first one (file descriptor) to be set for the second one.
dup2
___ will make a copy of the current process.
fork
___ is a type of file that points to another file.
symbolic link
Consider a code segment for a pipe (e.g., to run “ls | wc”) as we discussed in the classes, shown below.
What would it be the code segment using execlp for the “parent” process after setting the file descriptors for the pipe?
execlp(“ls”,”ls”,(char *)0);
The new file descriptor returned by dup is guaranteed to be the ___ numbered available file descriptor
lowest
Given fork program as shown below, what would be the total number of processes at the end including the process running this program initially.
for (i=1; i
1
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.
if (fork()
2
When a process calls one of the ____ functions, that process is completely replaced by the new program, and the new program starts executing at its main function. It merely replaces the current process its text, data, heap, and stack segments with a brand-new program from disk.
exec
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.
if (pid=fork()) {fork();}
if (pid=fork()) {fork();}
if (pid=fork()) {fork();}
27
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.
if fork() fork(
3
The new process created by fork is called the child process. This function is called once but returns ___.
twice
Consider a code segment for a pipe (e.g., to run “ls | wc”) as we discussed in the classes, shown below.
What would it be the code segment for the “parent” process after fork but before exec?
close(pfd[0]); dup2(pfd[1], 1); close(pfd[1]);
What would be a proper way to set a signal handler (sig_int) for SIGINT?
signal(SIGINT,sig_int);
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.
fork(); fork(); fork();
8
A process is
a program which is started but not terminated
After fork, the return value for the child is ___
0
After fork, the return value for the parent process is ___
the child process id
Signals provide a way of handling ___ events
asynchronous