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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started