Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a small program, sleepy , that gets a loop count from the command line: sleepy n where n is the number of seconds for

Write a small program, sleepy, that gets a loop count from the command line:

sleepy n

where n is the number of seconds for which the program should run. Implement this timing by putting a loop n times of sleep(1) - this will put the program to sleep for one second n times before exiting.

In each loop print out the process ID and the loop count so that that particular process can be identified.

The process ID can be obtained from the getpid function:

#include #include ... pid_t getpid(void);

This function returns the process ID of the calling process.

This is what I've done:

#include #include #include #include #include

int main(int argc, char* argv[])

{ int seconds; int i; if(isdigit(argv[i][0])){ seconds = atoi(argv[i]); printf("seconds = %d ", seconds); } int pid = (int) getpid(); int i; for (i = 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago