Unix exam 2

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

[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] By convention, all shells in Unix open ___ file descriptors whenever a new program is run.

3

[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] 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] 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

[APUE] Which one of the following statements is NOT correct for Process File Descriptors and Kernel's File Table?

A File Descriptor entry of a process is an array of file attributes

[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

[APUE07] Which one of the following statements is NOT correct?

A virtual address space is also called a physical address.

[APUE07] Which one of the following statements is correct for Data Segment?

It contains the global variables that are initialized by the programmer, and has a fixed size, but is not read-only

[APUE07] Which one of the following statements is correct for Stack Segment?

It contains the stack frames which keep track of the return addresses of calling functions as well as arguments passed to functions and local variables.

[APUE] Which one of the following statements is NOT correct for Process Table?

It is maintained by each process in the kernel's memory space

[APUE07] Which one of the following statements is correct for Text(Code) Segment?

It is the portion of the virtual address space that contains executable instructions.

[APUE07] Which one of the following statements is correct for Heap Segment?

It is used for runtime allocation of memory by processes

[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).

With File "open" call, this option ____ creates the file if it doesn't exist.

O_CREAT

[APUE03] With File "open" call, this option ____ generates an error if path doesn't refer to a directory.

O_DIRECTORY

[APUE03] With File "open" call, this option ____ generates an error if O_CREAT is also specified and the file already exists. This test for whether the file already exists and the creation of the file if it doesn't exist is an atomic operation.

O_EXCL

[APUE03] With File "open" call: if path refers to a FIFO, a block special file, or a character special file, this option ___ sets the nonblocking mode for both the opening of the file and subsequent I/O.

O_NONBLOCK

[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.

[APUE] Pressing Ctrl-C generate the signal ____.

SIGINT

[APUE] Which one of the following statements is NOT correct for "signal"?

SIGKILL can be handled by a process signal handler

[APUE04] ___ is a type of file that points to another file.

Symbolic link

[APUE03] With File "lseek" call, which one of the following statements is not correct?

The "current file offset" is initialized to 0 and the next write pointer is set to the end of the file if the O_APPEND option is specified.

[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."

[APUE03] Which one of the following statements is NOT correct? Consider Unix file IO (e.g., read and write).

The Iseek function modifies only the current file offset in the table entry. It forces I/O take place

[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.

[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] Which one of the following statements is NOT correct?

The function which removes a directory entry is always called "delete."

[APUE03] With "read" function, which one of the following statements is NOT correct?

The number of bytes actually read is always same as the amount requested for a successful read

[APUE] Which one of the following statements is NOT correct for Environment?

The order in which strings appear in the environment variable ("environ") is significant, and the same name must not appear more than once

[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] 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] 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.

[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.

[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.

[APUE] System calls using signals. ____ causes the system to generate a SIGALRM signal for the process after the specified number of real-time seconds have elapsed

alarm call

[Process2] Signals provide a way of handling ___ events

asynchronous

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

descriptor

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

dup2

[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] 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] What would be a proper way to set a signal handler (sig_int) for SIGINT?

signal(SIGINT, sig_int);

[APUE07] This ___ command displays the size of these sections in an executable file.

size

[Process2] ___ is a type of file that points to another file.

symbolic link

[Process2] For a convenience, ___ call is used to execute a command string (e.g., "ls -la | wc") within a program.

system

[Process2] After fork, the return value for the parent process is ___

the child process id

[Process2] After fork, the return value for the child is ___

0

[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

[APUE04] Which one of the following statements is NOT correct?

Any user can create a hard or symbolic link to a directory

[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] 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.

[APUE] Which one of the following items is NOT provided as a standard Unix or Linux IPC means?

Cloud

[APUE04] Which one of the following statements is not correct?

Given a pathname, the function nstat obtains the information about the named file.

[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).

[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.

[APUE04] Which one of the following statements is NOT correct?

In all modern systems, chown does not follow symbolic links.

[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? 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

[APUE04] The ____ function sets the file mode creation mask for the process and returns the previous value.

Unmask

[APUE03] With "lseek" call, which one of the following statements is NOT correct?

Using the file's offset greater than the file's current size, one can create a hole in a file and is not allowed as a legal file operation.

[APUE] Which one of the following statements is NOT correct for Child Process termination?

When a child process dies, the parent process must be wake up.

[APUE03] Which one of the following statements is NOT correct? Consider the following dup and dup2 calls. #include <unistd.h> 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.

[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

[APUE07] This ___ command displays library dependencies.

ldd

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

lowest

[APUE07] This command displays Symbols in a given file (a binary executable).

nm

[APUE] System calls use signals. ____ suspends the calling process until it receives a signal.

pause call

[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] 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

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

twice

[APUE04] Which one of the following statements is not correct? The stat function returns ___ of the following file information.

v-node number

[APUE03] With "read" function, consider the cases for the number of bytes actually read is less than the amount requested. Which one of the following statements is NOT correct?

when reading a full data done but a signal may cause its partial data to be lost


Ensembles d'études connexes

Chapter 2 Adjuster Duties & Reponsibilities

View Set

Intro to Computers- Chapter 4 Key Terms

View Set

Nurs 4 - RN EAQ's -QSEN: Patient Centered Care

View Set

Chapter 10: Payroll Computations, Records, and Payments

View Set

Lección 8: Recapitulaión y Prueba de práctica

View Set