The receipt of the signal triggers some action by the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: d.h> unsigned int sleep(unsigned int secs); returns: seconds left to sleep Sleep returns zero if the requested amount of time has elapsed, and the number of seconds still left to sleep otherwise. The latter case is possible if the sleep function returns prematurely because it was interrupted by a signal. We will discuss signals in detail in Section 8.5. Another function that we will find useful is the pause function, which puts the calling function to sleep until a signal is received by the process. #include <unistd.h> int pause(void); always returns -1 8.4. PROCESS CONTROL Practice Problem 8.5: Write a wrapper function for sleep, called snooze, with the following interface: unsigned int snooze(unsigned int secs); The snooze function behaves exactly as the sleep function, except that it prints a message describing how long the process actually slept. For example, Slept for 4 of 5 secs. 415 8.4.5 Loading and Running Programs The execve function loads and runs a new program in the context of the current process. #include <unistd.h> int execve(char *filename, char *argv, char *envp); does not return if OK, returns -1 on error The execve function loads and runs the executable object...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online