Related differences

Linux vs Unix

Ques 21. What is a pipe and give an example?

A pipe is two or more commands separated by pipe char '|'. That tells the shell to arrange for the output of the preceding command to be passed as input to the following command.
Example : ls -l | pr
The output for a command ls is the standard input of pr.
When a sequence of commands are combined using pipe, then it is called pipeline.

Is it helpful? Add Comment View Comments
 

Ques 22. Explain kill() and its possible return values.

There are four possible results from this call:
'kill()' returns 0. This implies that a process exists with the given PID, and the system would allow you to send signals to it. It is system-dependent whether the process could be a zombie.
?kill()? returns -1, ?errno == ESRCH? either no process exists with the given PID, or security enhancements are causing the system to deny its existence. (On some systems, the process could be a zombie.)
?kill()? returns -1, ?errno == EPERM? the system would not allow you to kill the specified process. This means that either the process exists (again, it could be a zombie) or draconian security enhancements are present (e.g. your process is not allowed to send signals to *anybody*).
?kill()? returns -1, with some other value of ?errno? you are in trouble! The most-used technique is to assume that success or failure with ?EPERM? implies that the process exists, and any other error implies that it doesn't.
An alternative exists, if you are writing specifically for a system (or all those systems) that provide a ?/proc? filesystem: checking for the existence of '/proc/PID' may work.

Is it helpful? Add Comment View Comments
 

Ques 23. How are devices represented in UNIX?

All devices are represented by files called special files that are located in/dev directory.
Thus, device files and other files are named and accessed in the same way. A 'regular file'
is just an ordinary data file in the disk. A 'block special file' represents a device with
characteristics similar to a disk (data transfer in terms of blocks). A 'character special file'
represents a device with characteristics similar to a keyboard (data transfer is by stream of
bits in sequential order).

Is it helpful? Add Comment View Comments
 

Ques 24. What is 'inode'?

All UNIX files have its description stored in a structure called 'inode'. The inode contains
info about the file-size, its location, time of last access, time of last modification,
permission and so on. Directories are also represented as files and have an associated
inode. In addition to descriptions about the file, the inode contains pointers to the data
blocks of the file. If the file is large, inode has indirect pointer to a block of pointers to
additional data blocks (this further aggregates for larger files). A block is typically 8k.
Inode consists of the following fields:
File owner identifier
File type
File access permissions
File access times
Number of links
File size
Location of the file data

Is it helpful? Add Comment View Comments
 

Ques 25. Brief about the directory representation in UNIX

A Unix directory is a file containing a correspondence between filenames and inodes. A directory is a special file that the kernel maintains. Only kernel modifies directories, but processes can read directories. The contents of a directory are a list of filename and inode number pairs. When new directories are created, kernel makes two entries named '.' (refers to the directory itself) and '..' (refers to parent directory).
System call for creating directory is mkdir (pathname, mode).

Is it helpful? Add Comment View Comments
 

Most helpful rated by users: