Fork (system call)
fork is an operation whereby a process creates a copy of itself. It is usually a system call, implemented in the kernal. Fork is the primary (and historically, only) method of process creation on Unix-like operating systems.fork() creates a new process by duplicating the calling process. The new process, referred to as the child, is an exact duplicate of the calling process, referred to as the parent, except for the following points:
The child has its own unique process ID, and this PID does not match the ID of any existing process group.
The child’s parent process ID is the same as the parent’s process ID.
- Vfork
Vfork is a variant of fork with the same calling convention and much the same semantics; it originated in the 3BSD version of Unix,the first Unix to support virtual memory. It was standardized by POSIX, which permitted vfork to have exactly the same behavior as fork, but marked obsolescent in the 2004 edition, and has disappeared from subsequent editions.
When a vfork system call is issued, the parent process will be suspended until the child process has either completed execution or been replaced with a new executable image via one of the “exec” family of system calls.
Pipes
A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin) to another. UNIX shell has a special syntax for creation of pipelines. The commands are written in sequence separated by.
A very useful Linux feature is named pipes which enable different processes to communicate.
Named pipea named pipe (also known as a FIFO for its behavior) is an extension to the traditional pipe concept on Unix and Unix-like systems, and is one of the methods of (IPC). The concept is also found in Microsoft window, although the semantics differ substantially. A traditional pipe because it exists anonymously and persists only for as long as the process is running. A named pipe is system-persistent and exists beyond the life of the process and must be deleted once it is no longer being used. Processes generally attach to the named pipes (usually appearing as a file) to perform inter-process communication.
I/O operations on a FIFO are essentially the same as for normal pipes, with once major exception. An “open” system call or library function should be used to physically open up a channel to the pipe. With half-duplex pipes, this is unnecessary, since the pipe resides in the kernel and not on a physical filesystem. In our examples, we will treat the pipe as a stream, opening it up with fopen(), and closing it with fclose().