APUE7-8 Process2

Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. 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();}
16
27
32
48
64
The new process created by fork is called the child process. This function is called once but returns ___.
None
Once
Twice
Three times
As many as needed
Given fork program as shown below, what would be the total number of processes at the end including the process running this program. for (i=1; I < nprocs; i++) { childpid = fork(); } When nprocs = 3, then the total number of processes after this code will be ____
1
2
4
8
16
This instruction ___ takes two (file descriptor) arguments, to duplicate the first one (file descriptor) to be set for the second one.
Hidden
Dup
Dup2
Fd
Pipe
This instruction ___ takes two (file descriptor) arguments, to duplicate the first one (file descriptor) to be set for the second one.
Execlp("wc","wc",(char *)0);
Execlp("ls","ls",(char *)0);
Execlp("system","wc",(char *)0);
Execlp("ls | wc",(char *)0);
After fork, the differences between the parent and child are:
The return values from fork
The process IDs
The different parent process IDs
All of the above
None of the above
When a process calls this API call (or one of these API calls), 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.
Fork
Exec
Pipe
Dup
System
What would be a proper way to set a signal handler (sig_int) for SIGINT?
SIGINT(sig_int);
Sigint(SIGINT);
SIGINT(signal, sig_int);
Signal(SIGINT, sig_int);
Signal(sig_int, SIGINT);
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 here after the fork but before exec (of "ls" or "wc")?
Close(pfd[0]); dup2(pfd[1], 1); close(pfd[1]);
Close(pfd[0]); dup2(pfd[1], 0); close(pfd[1]);
Close(pfd[1]); dup2(pfd[0], 1); close(pfd[0]);
Close(pfd[1]); dup2(pfd[0], 0); close(pfd[0]);
By convention, UNIX System shells associate the file descriptor __ with the standard input of a process.
0
1
2
3
-1
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();}
8
9
16
27
32
By convention, all shells in Unix open ___ file descriptors whenever a new program is run.
0
1
2
3
4
As many as needed
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. if (fork() < 0) {fork();}
1
2
3
4
0
After fork, the return value for the child is ___
-1
0
+1
A new process ID for the child process
The process id of the parent process
The new file descriptor returned by dup is guaranteed to be the ___ numbered available file descriptor
Lowest
Highest
Fixed
Stack
Arbitrary
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. fork(); fork(); fork();
1
4
6
8
16
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. If fork() fork();
1
2
3
4
0
After fork, the return value for the parent process is ___
-1
0
+1
Correct
The child process id
The process id of the parent process
___ is a type of file that points to another file.
Symbolic link
Directory file
FIFO
Pipe
Dupe
A file ___ is normally small non-negative integer that the kernel uses to identify the files accessed by a process.
Buffer
Table
Descriptor
I-node
Entry
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
None of the above
For a convenience, ___ call is used to execute a command string (e.g., "ls -la | wc") within a program.
Thread
Process
Pipe
Fork
System
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.
Cylinder
Disk
File block
I-node
Dup
Signals provide a way of handling ___ events
Deadlocked
Racing
Asynchronous
Synchronous
Idle-process
___ will make a copy of the current process.
Spawn
Clone
Thread
Fork
Dup
{"name":"APUE7-8 Process2", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below. 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();}, The new process created by fork is called the child process. This function is called once but returns ___., Given fork program as shown below, what would be the total number of processes at the end including the process running this program. for (i=1; i < nprocs; i++) { childpid = fork(); } When nprocs = 3, then the total number of processes after this code will be ____","img":"https://cdn.poll-maker.com/15-651323/pipeforkdup2exec1.png?sz=1200"}
Powered by: Quiz Maker