Question: Write a whattime.c program which accepts either a -f or -d argument or no arguments at all. If the program is run with either no

Write a whattime.c program which accepts either a -f or -d argument or no arguments at all. If the program is run with either no arguments or the -f argument, then the program runs in the foreground and outputs it's results to stdout. If -d is given when the program is run, then it immediately becomes a daemon and runs in the background (detached from any terminals) and logs to a file called mydeamon.log. Whether the program runs in the foreground or background doesn't matter, the program should always run for one minute. Every two seconds your program should re port the number of seconds since 1/1/1970 12:00am and also the username and home directory of the user who started the program up (refer to getenv function in stdlib.h). And by report I mean if you run in the foreground, then display the results to stdout, if run as a daemon, then output to the log file.

Write a whattime.c program which accepts either a -f or -d argument

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!