1/108
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Including the initial parent process, the total number of the processes (in total) will be ____ after executing the code segment below.
64
The new file descriptor returned by dup is guaranteed to be the ___ numbered available file descriptor
lowest
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);
A process may do ___ with the signal
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 (fork() < 0) {fork();}
2
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
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
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]);
This instruction ___ takes two (file descriptor) arguments, to duplicate the first one (file descriptor) to be set for the second one.
dup2
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
After fork, the return value for the parent process is ___
the child process id
After fork, the return value for the child is ___
0
By convention, UNIX System shells associate the file descriptor __ with the standard input of a process.
0
A file ___ is normally small non-negative integer that the kernel uses to identify the files accessed by a process
descriptor
After fork, the differences between the parent and child are ____.
All 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.
exec
___ is a type of file that points to another file.
symbolic link
The new process created by fork is called the child process. This function is called once but returns ___.
twice
Signals provide a way of handling ___ events
asynchronous
If a process needs a child process to do some of its work, it will call ___ to make a copy of the current process.
fork
For a convenience, ___ call is used to execute a command string (e.g., "ls -la | wc") within a program.
system
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
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 ____
4
By convention, all shells in Unix open ___ file descriptors whenever a new program is run.
3
What would be a proper way to set a signal handler (sig_int) for SIGINT?
signal(SIGINT, sig_int);
[Process2] 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]);
[Process2] For convenience, ___ call is used to execute a command string (e.g., "ls -la | wc") within a program.
system
[Process2] 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
[Process2] This instruction ___ takes two (file descriptor) arguments, to duplicate the first one (file descriptor) to be set for the second one.
dup2
[Process2] ___ is a type of file that points to another file.
symbolic link
[Process2] The new file descriptor returned by dup is guaranteed to be the ___ numbered available file descriptor
lowest
[Process2] 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
[Process2] 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
[Process2] 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
[Process2] By convention, all shells in Unix open ___ file descriptors whenever a new program is run.
3
[Process2] Signals provide a way of handling ___ events
asynchronous
[Process2] After fork, the return value for the parent process is ___
the child process id
[Process2] What would be a proper way to set a signal handler (sig_int) for SIGINT?
signal(SIGINT, sig_int);
[Process2] A file ___ is normally small non-negative integer that the kernel uses to identify the files accessed by a process.
descriptor
[Process2] 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 ____
4
[Process2] If a process needs a child process to do some of its work, it will call ___ to make a copy of the current process.
fork
[Process2] 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();}
2
[Process2] 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.
exec
[Process2] After fork, the return value for the child is ___
0
[Process2] The new process created by fork is called the child process. This function is called once but returns ___.
twice
[APUE04] The directories /tmp and /var/tmp are typical candidates for ___.
These are directories in which any user can typically create files. The permissions for these two directories are often read, write, and execute for everyone (user, group, and other). But users should not be able to delete or rename files owned by others.
- the directory access bit
- the user write bit
- the user execute bit
- the sticky bit
- the special bit
the sticky bit
[APUE04] Which one of the following statements is NOT correct?
Consider the file and/or directory access, and chmod command.
- To open the file /usr/include/stdio.h, we need execute permission in the directory /, execute permission in the directory /usr, and execute permission in the directory /usr/include.
- If the current directory is /usr/include, then we need execute permission in the current directory to open the file stdio.h.
- Read permission lets us read the directory, obtaining and searching through a list of all the filenames in the directory.
- Execute permission lets us pass through the directory when it is a component of a pathname that we are trying to access (in order to search the directory to look for a specific filename).
- If the PATH environment variable specifies a directory that does not have execute permission enabled, the shell will never find executable files in that directory.
Read permission lets us read the directory, obtaining and searching through a list of all the filenames in the directory.
[APUE04] The ____ function sets the file mode creation mask for the process and returns the previous value.
- access
- chmod
- mask
- mode
- umask
umask
[APUE04] Which one of the following statements is NOT correct?
Consider the file and/or directory access.
- The read permission for a file determines whether we can open an existing file for reading: the O_RDONLY and O_RDWR flags for the open function.
- The write permission for a file determines whether we can open an existing file for writing: the O_WRONLY and O_RDWR flags for the open function.
- We must have write permission for a file to specify the O_TRUNC flag in the open function.
- We cannot create a new file in a directory unless we have write permission and execute permission in the directory.
- To delete an existing file, we need only the write permission for the file itself.
- Execute permission for a file must be on if we want to execute the file using any of the seven exec functions. The file also has to be a regular file.
To delete an existing file, we need only the write permission for the file itself.
[APUE04] Which one of the following statements is NOT correct?
Consider umask bits.
- The umask value 0000 is to allow anyone to do read, write, or execute the files
- The umask value 0002 is to prevent others from writing the files
- The umask value 0022 is to prevent group members and others from writing the files
- The umask value 0027 is to prevent group members from writing your files and others from reading, writing, or executing the files.
- The umask value 0700 is to allow the user (owner) to read, write, or execute the files
The umask value 0700 is to allow the user (owner) to read, write, or execute the files
[APUE04] Which one of the following statements is NOT correct?
Consider umask command.
- Users can set the umask value to control the default permissions on the files they create.
- The umask value is expressed in octal, with one bit representing one permission to be masked off.
- With umask value, the permissions can be denied by setting the corresponding bits.
- The Single UNIX Specification requires that the umask command support a symbolic mode of operation.
- Like the octal format with umask command, the symbolic format specifies which permissions are to be denied (i.e., clear in the file creation mask) instead of which ones are to be denied (i.e., set in the file creation mask).
Like the octal format with umask command, the symbolic format specifies which permissions are to be denied (i.e., clear in the file creation mask) instead of which ones are to be denied (i.e., set in the file creation mask).
[APUE04] Which one of the following statements is NOT correct?
- There are two types of links: hard link and symbolic link.
- Any user can create a hard or symbolic link to a directory.
- A symbolic link is an indirect pointer to a file.
- A hard link points directly to the i-node of the file.
- Hard links normally require that the link and the file reside in the same file system.
Any user can create a hard or symbolic link to a directory.
[APUE04] Which one of the following statements is NOT correct?
Consider the following commands.
$ ln -s /no/such/file myfile
$ ls myfile
myfile
$ cat myfile
cat: myfile: No such file or directory
$ ls -l myfile
lrwxrwxrwx 1 sar 13 Jan 22 00:26 myfile -> /no/such/file
- The "ln" command creates a symbolic link. Here a symbolic link is created to point a file named "myfile."
- The file "myfile" does exist, yet cat says there is no such file, because "myfile" is a symbolic link.
- Here the file pointed to by the symbolic link doesn't exist.
- The -l option to "ls" command gives us one hint: the first character is an l, which means a symbolic link.
- The -l option to "ls" command gives us one hint: the sequence -> also indicates a symbolic link.
- The ls command with option (-F) that appends an at-sign (@) to filenames that are symbolic links.
The "ln" command creates a symbolic link. Here a symbolic link is created to point a file named "myfile."
[APUE04] Which one of the following statements is NOT correct?
- Using mkdir command, a directory ("testdir") has been just created under a directory. This will create two new links: one link pointing to "dot" directory entry and the other for "dot-dot" directory entry.
- Every i-node has a link count that contains the number of directory entries that point to it.
- Only when the link count of i-node goes to 0 can the file be deleted, thereby releasing the data blocks associated with the file.
- The operation of "unlinking a file" does not always mean "deleting the blocks associated with the file."
- The function which removes a directory entry is always called "delete."
The function which removes a directory entry is always called "delete."
[APUE04] ___ is a type of file that points to another file.
- Regular file
- Directory file
- Block Special file
- Character Special file
- FIFO
- Socket
- Symbolic link
Symbolic link
[APUE04] Which one of the following statements is NOT correct?
Consider the file and/or directory access. The file access tests that the kernel performs each time a process opens, creates, or deletes a file depend on the owners of the file (st_uid and st_gid), the effective IDs of the process (effective user ID and effective group ID), and the supplementary group IDs of the process, if supported.
- The two owner IDs are properties of the file, whereas the two effective IDs and the supplementary group IDs are properties of the process. The tests performed by the kernel are as follows:
- If the effective user ID of the process is 0 (the superuser), access is allowed. This gives the superuser free rein throughout the entire file system.
- If the effective user ID of the process equals the owner ID of the file (i.e., the process owns the file), access is allowed if the appropriate user access permission bit is set. Otherwise, permission is denied.
- If the process is executing the file, the user-execute bit must be on if the process group ID of the process equals the group ID of the file (i.e., the process group owns the file).
- If the effective group ID of the process or one of the supplementary group IDs of the process equals the group ID of the file, access is allowed if the appropriate group access permission bit is set. Otherwise, permission is denied.
- If the appropriate other access permission bit is set, access is allowed. Otherwise, permission is denied.
If the process is executing the file, the user-execute bit must be on if the process group ID of the process equals the group ID of the file (i.e., the process group owns the file).
[APUE04] Every process has six or more IDs associated with it.
____ identify who we really are. These two fields are taken from our entry in the password file when we log in. Normally, these values don't change during a login session, although there are ways for a superuser process to change them.
- The real user ID and the real group ID
- The effective user ID and the effective group ID
- The saved set-user-ID and the saved set-group-ID
- The virtual user ID and the virtual group ID
- The system user ID and the system group ID
The real user ID and the real group ID
[APUE04] Which one of the following statements is not correct?
Consider the file and/or directory access, and chmod command.
- The chmod command is typically used to modify the six permission bits.
- The chmod command allows one to specify u for user (owner), g for group, and o for other.
- The three categories (read, write, and execute) are used in various ways by different functions with the chmod command.
- Whenever we want to open any type of file by name, we must have execute permission in each directory mentioned in the name, including the current directory, if it is implied.
- The excute-permission bit for a directory is often called the search bit.
The chmod command is typically used to modify the six permission bits.
[APUE04] Which one of the following statements is NOT correct?
Using mkdir command, testdir has been just created. Consider the figure below as a result.
- The i-node whose number is 2549 has a type field of ''directory'' and a link count equal to 3.
- Any leaf directory (a directory that does not contain any other directories) always has a link count of 2.
- The value (the link count) of 2 for the i-node of 2549 comes from the directory entry that names the directory (testdir) and from the entry for dot in that directory.
- The i-node whose number is 1267 has a type field of ''directory'' and a link count that is greater than or equal to 3.
- Every subdirectory in a parent directory causes the parent directory's link count to be increased by 1.
The i-node whose number is 2549 has a type field of ''directory'' and a link count equal to 3.
[APUE04] Which one of the following statements is NOT correct?
- Symbolic links are typically used to ''move'' a file or an entire directory hierarchy to another location on a system.
- If the function follows a symbolic link, a pathname argument to the function refers to the file pointed to by the symbolic link.
- In all modern systems, chown does not follow symbolic links.
- There are no file system limitations on a symbolic link and what it points to.
- Anyone can create a symbolic link to a directory.
In all modern systems, chown does not follow symbolic links.
[APUE04] On contemporary systems, the use of ___ has been extended. The Single UNIX Specification allows this bit to be set for a directory. If this is set for a directory, a file in the directory can be removed or renamed only if the user has write permission for the directory and meets one of the following criteria: (a) Owns the file, (b) Owns the directory, and (c) Is the superuser.
- the directory access bit
- the user write bit
- the user execute bit
- the sticky bit
- the special bit
the sticky bit
[APUE04] Which one of the following statements is not correct?
Consider umask.
- Most users of UNIX systems never deal with their umask value.
- umask value is usually set once, on login, by the shell's start-up file, and never changed.
- Writing programs that create new files, if we want to ensure that specific access permission bits are enabled, we must modify the umask value while the process is running.
- To ensure that anyone can read a file, we should set the umask to 0777.
- The umask value that is in effect when our process is running can cause permission bits to be turned off.
To ensure that anyone can read a file, we should set the umask to 0777.
[APUE04] Every process has six or more IDs associated with it. This ____ determines one's file access permissions.
- The real user ID and the real group ID
- The effective user ID and the effective group ID
- The saved set-user-ID and the saved set-group-ID
- The virtual user ID and the virtual group ID
- The system user ID and the system group ID
The effective user ID and the effective group ID
[APUE04] Which one of the following statements is not correct?
The stat function returns ___ of the following file information.
- file type & mode (permissions)
- i-node number (serial number)
- v-node number
- number of links
- user ID of owner
- size in bytes, for regular files
- time of last access
- time of last modification
v-node number
[APUE04] Which one of the following statements is not correct?
- Given a pathname, the stat function returns a structure of information about the named file.
- Given a pathname, the fstat function obtains the information about the file that is already open on the descriptor.
- Given a pathname, the lstat function is similar to stat, but when the named file is a symbolic link, lstat returns the information about the symbolic link, not the file referenced by the symbolic link.
- Given a pathname, the function nstat
obtains the information about the named file.
- Given a pathname, the fstatat function provides a way to return the file statistics for a pathname relative to an open directory represented by the fd argument.
Given a pathname, the function nstat
obtains the information about the named file.
[APUE04] Which one of the following statements is not correct?
The stat function returns ___ of the following file information.
v-node number
[APUE04] Which one of the following statements is NOT correct?
The function which removes a directory entry is always called "delete."
[APUE04] Which one of the following statements is NOT correct?
Consider umask command.
Like the octal format with umask command, the symbolic format specifies which permissions are to be denied (i.e., clear in the file creation mask) instead of which ones are to be denied (i.e., set in the file creation mask).
[APUE04] Which one of the following statements is NOT correct?
Consider the file and/or directory access.
To delete an existing file, we need only the write permission for the file itself.
[APUE04] Which one of the following statements is not correct?
Consider umask.
To ensure that anyone can read a file, we should set the umask to 0777.
[APUE04] Every process has six or more IDs associated with it. This ____ determines one's file access permissions.
The effective user ID and the effective group ID
[APUE04] Every process has six or more IDs associated with it. Which one of the following statements is NOT correct?
The virtual user ID and the virtual group ID
[APUE04] Every process has six or more IDs associated with it. Which one of the following statements is NOT correct?
When one executes a program file, the effective user ID of the process is usually the virtual user ID, and the effective group ID is usually the virtual group ID.
[APUE04] Every process has six or more IDs associated with it.
____ identify who we really are. These two fields are taken from our entry in the password file when we log in. Normally, these values don't change during a login session, although there are ways for a superuser process to change them.
The real user ID and the real group ID
[APUE04] The ____ function sets the file mode creation mask for the process and returns the previous value.
umask
[APUE04] Which one of the following statements is NOT correct?
Using mkdir command, testdir has been just created. Consider the figure below as a result.
The i-node whose number is 2549 has a type field of ''directory'' and a link count equal to 3.
[APUE04] Which one of the following statements is NOT correct?
Consider the file and/or directory access. The file access tests that the kernel performs each time a process opens, creates, or deletes a file depend on the owners of the file (st_uid and st_gid), the effective IDs of the process (effective user ID and effective group ID), and the supplementary group IDs of the process, if supported.
The two owner IDs are properties of the file, whereas the two effective IDs and the supplementary group IDs are properties of the process. The tests performed by the kernel are as follows:
If the process is executing the file, the user-execute bit must be on if the process group ID of the process equals the group ID of the file (i.e., the process group owns the file).
[APUE04] Every process has six or more IDs associated with it. The saved set-user-ID and saved set-group-ID contain copies of ___, respectively, when a program is executed.
The effective user ID and the effective group ID
[APUE04] The directories /tmp and /var/tmp are typical candidates for ___.
These are directories in which any user can typically create files. The permissions for these two directories are often read, write, and execute for everyone (user, group, and other). But users should not be able to delete or rename files owned by others.
the sticky bit
[APUE04] Every process has six or more IDs associated with it. Normally, the effective user ID and the effective group ID equals ____ respectively.
The real user ID and the real group ID
[APUE04] On contemporary systems, the use of ___ has been extended. The Single UNIX Specification allows this bit to be set for a directory. If this is set for a directory, a file in the directory can be removed or renamed only if the user has write permission for the directory and meets one of the following criteria: (a) Owns the file, (b) Owns the directory, and (c) Is the superuser.
the sticky bit
[APUE04] Which one of the following statements is NOT correct?
Consider the file and/or directory access, and chmod command.
Read permission lets us read the directory, obtaining and searching through a list of all the filenames in the directory.
[APUE04] Every process has six or more IDs associated with it.
____ contain copies of the effective user ID and the effective group ID, respectively, when a program is executed.
The saved set-user-ID and the saved set-group-ID
[APUE04] Which one of the following statements is NOT correct?
Consider umask bits.
The umask value 0700 is to allow the user (owner) to read, write, or execute the files
[APUE03] For file IO with buffering, consider the following statistics for a benchmark. The file was read using the program here with standard output redirected to /dev/null. The file system used for this test was the Linux ext4 file system with 4,096-byte blocks.
Which one of the following statements is NOT correct?
Bigger the buffer size means better in performance evidenced in this statistics.
[APUE03] Most file I/O on a UNIX system can be performed using only five functions. Which one of the following is NOT correct?
seek
[APUE03] Which one of the following statements is NOT correct?
This convention of the designation of the file descriptors 0,1,2 (of a running process) is a standard and feature of the UNIX kernel.
[APUE03] Which one of the following statements is NOT correct?
In POSIX-compliant applications, file descriptor 0 is replaced with the symbolic constants STDERR_FILENO
[APUE03] Which one of the following statements is NOT correct?
With FreeBSD 8.0, Linux 3.2.0, Mac OS X 10.6.8, and Solaris 10, the limit of the maximum number of file descriptors is ___.
incremented by the multiples of file block size
[APUE03] Which one of the following statements is NOT correct?
For file "open" function call, one of the constants for the options is ___.
O_APONLY [open for appending only].
[APUE03] Which one of the following statements is NOT correct?
Associated with each file descriptor are the file descriptor flags and a pointer to a file table entry, and inode.
[APUE03] Which one of the following statements is NOT correct?
The kernel maintains a file table for all open files of which each file table entry contains _____.
a file descriptor
[APUE03] Which one of the following choices is NOT correct about i-node.
Unix does not have v-node. Instead, a generic i-node structure is used.
[APUE03] Which one of the following choices is NOT correct about v-node.
In SVR4, the v-node replaced the file system-independent i-node of SVR3. Solaris is derived from SVR4 and, therefore, uses i-nodes only.
[APUE03] Which one of the following statements is correct?
The following figure shows ____.
how two processes can share a file
[APUE03] Which one of the following statements is NOT correct? Consider the following figure.
One reason each process gets its own file table entry is so that each process can share its own current file IO status with the other.
[APUE03] Which one of the following statements is NOT correct? Consider Unix file IO (e.g., read and write).
The lseek function modifies only the current file offset in the file table entry. It forces I/O take place.
[APUE03] Which one of the following statements is NOT correct?
In general, the term atomic operation refers to an operation consisting of multiple steps where each step can be interruptible for an atomic signal.
[APUE03] Which one of the following statements is NOT correct? Consider the following dup and dup2 calls.
#include
int dup(int fd);
int dup2(int fd, int fd2);
With dup2, if fd2 is already open, it will generate FD_CLOEXEC to close the file and then open it.
[APUE03] Which one of the following statements is NOT correct?
The file descriptor is returned by creat as an argument to either read or write.