unix test 2 review Flashcards

1
Q

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.

A

i- node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

By convention, all shells in Unix open ___ file descriptors whenever a new program is run.

A

3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
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
A

All of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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();}

A

27

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A ___ has only one thread of control - one set of machine instructions executing at a time.

A

process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
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
A

All of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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();}

A

64

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A file ___ is normally small non-negative integer that the kernel uses to identify the files accessed by a process.

A

descriptor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

By convention, UNIX System shells associate the file descriptor __ with the standard input of a process.

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

This instruction ___ takes two (file descriptor) arguments, to duplicate the first one (file descriptor) to be set for the second one.

A

dup2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

___ will make a copy of the current process.

A

fork

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

___ is a type of file that points to another file.

A

symbolic link

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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?

A

execlp(“ls”,”ls”,(char *)0);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The new file descriptor returned by dup is guaranteed to be the ___ numbered available file descriptor

A

lowest

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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

A

1

17
Q

Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.

if (fork()

A

2

18
Q

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.

A

exec

19
Q

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();}

A

27

20
Q

Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.

if fork() fork(

A

3

21
Q

The new process created by fork is called the child process. This function is called once but returns ___.

A

twice

22
Q

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?

A

close(pfd[0]); dup2(pfd[1], 1); close(pfd[1]);

23
Q

What would be a proper way to set a signal handler (sig_int) for SIGINT?

A

signal(SIGINT,sig_int);

24
Q

Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.

fork(); fork(); fork();

A

8

25
Q

A process is

A

a program which is started but not terminated

26
Q

After fork, the return value for the child is ___

A

0

27
Q

After fork, the return value for the parent process is ___

A

the child process id

28
Q

Signals provide a way of handling ___ events

A

asynchronous