Signals are similar to interrupts, in that the receiving process's execution is interrupted to handle the signal - in most cases the process is aborted. When a user types '[ctrl] + [c] ' at the terminal, a SIGINT signal is sent to the foreground process. Main Features of signals: • Asynchronous • Sender must know PID of target • Specific numbers are associated with the signals • Only processes with the same UID may exchange signals • Signal handling can be done by the programmer How they are generated: • A process may explicitly send a signal to one or more processes using the kill system call • The terminal driver generates signals to processes connected to it in response to certain keyboard events • The kernel generates a signal to notify the process of a hardware exception, or of a condition such as exceeding a quota Signals all have a default action: • Process termination • Ignored • Suspend Process Alternatively users can use the signal system call to run a specific method on the instance of a specific signal using signal(SIGALRM, methodToRun) The SIGKILL signal is the only signal that cannot be trapped regardless of the traps it employs. Sending Signals PID is the process ID, and sig is the signal being sent kill(PID,sig) Posted by asbo at 15:39 0 comments Pipes Pipes permit two or more processes to send data to each other. There are two types of pipes in UNIX: • anonymous • named Introduction to Anonymous Pipes: Anonymous pipes provide a half-duplex communication between two processes. A pipe acts as a file, the process is often unaware that the file it is writing to, or reading from, is a pipe. processes will be blocked when writing to a pipe when it is full until the other process reads from it. Reading from an empty pipe will have a similar effect. If the kernel cannot allocate enough space for a new pipe, the system call returns a value ' -1 ' , else it returns ' 0 '. Rules for writing to an Anonymous pipe: • If the read end has been closed, the write fails and the SIGPIPE signal is sent, default action is to terminate the receiver. • If a process writes less data to the pipe than the pipe can hold then the data sent will be atomic, else the process is blocked after each write until the pipe has more capacity for it(until the other end is read) Rules for reading from an Anonymous pipe: • When the write end of a pipe is closed, the read will return a zero indicating end of input. • While a pipe is empty and the write end is open, the process will sleep until data becomes available. • If a process tries to read more from a pipe than is present, the number of bytes actually read are returned. Sequence of Events: • Parent process creates anonymous pipe • Parent process forks • Writer closes read end of pipe, and the reader closes the write end • Processes communicate by using 'write' and 'read' calls • Each process closes its active pipe descriptor when it is no longer required Limitation of Anonymous pipes: • Only related processes can use them • On termination of creating process all data stored in the pipe is lost. Named Pipes A named pipe allows any two processes to communicate in a full-duplex fashion. A permanent UNIX file is used. They have buffer capacity at approx 40K. They can be created using the mknod shell command, or the mknod() system call. It can be opened by any number of processes for reading and writing. Data is written to a named pipe will remain there after the processes terminate.