16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Processes I<br />

F_SETFL set status flags via arg<br />

F_GETFL return status flags via arg<br />

F_GETLK, F_SETLK, F_SETLKW record locking<br />

#include device specific operations<br />

int ioctl (int fildes, unsigned long request, char *arg);<br />

intended for device specific operations<br />

! signals<br />

Notification to a process that an event has occurred "software interrupt" usually occur asynchronously.<br />

- by one process to ano<strong>the</strong>r process<br />

- by <strong>the</strong> kernel to a process<br />

#include <br />

Name Description Default action<br />

ISIGALRM Alarm clock Terminate<br />

ISIGBUS Bus error Terminate core<br />

ISIGCLD Death of child process Discarded<br />

ISIGEMT EMT instruction Terminate core<br />

ISIGFPE FPE instruction Terminate core<br />

ISIGHUP Hangup Terminate<br />

ISIGILL Illegal instruction Terminate core<br />

ISIGINT Interrupt character Terminate<br />

ISIGIOT IOT instruction Terminate core<br />

ISIGKILL Kill Terminate<br />

ISIGPIPE Write on pipe no one read it Terminate<br />

ISIGPOLL Select event on stream device Terminate<br />

ISIGPWR Power fail Terminate<br />

ISIGQUIT Quit character Terminate core<br />

ISIGSEGV Segmentation violation Terminate core<br />

ISIGSYS Bad argument to system call Terminate core<br />

ISIGTERM Software termination signal Terminate<br />

ISIGTRAP Trace trap Terminate core<br />

ISIGUSRl User defined signal 1 Terminate<br />

ISIGUSR2 User defined signal 1 Terminate<br />

- How and when are signals sent?<br />

1. kill system call (kill is a misnomer)<br />

allows a process to sending process and send a signal to ano<strong>the</strong>r process. To send a signal, <strong>the</strong> receiving<br />

process must both have <strong>the</strong> same effective user ID.<br />

2. kill command<br />

is also used to send signals<br />

3. terminal-generated signals e.g. interrupt character AC generates SIGINT signal<br />

4. hardware conditions e.g. floating point error generates SIGFPE error<br />

5. software conditions<br />

<strong>the</strong> kernel causes signals to be generated e.g. SIGURG out-of-band data arrives on a socket<br />

- What can a process do <strong>with</strong> a signal?<br />

1. Provide a function called a signal handler<br />

2. Ignore a signal (except SIGKILL terminate any process)<br />

3. Allow <strong>the</strong> default action to occur<br />

- To handle a signal from <strong>with</strong>in a process:<br />

#include <br />

int (*signal (int sig, void (*func) (in))) (int);<br />

signal: is a function that returns a pointer to a function that returns an integer.<br />

116

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!