/* filename : processm.c created : [creation date : eg, 01.20.08] modified : [modification date : eg, 02.01.08] Author : [authors name] Description : [brief description of what this source file does] Reports/ Logs ************* Date Desc ******************** 01.20.08 Memory report, Completed and Working. 01.21.08 Process report,, in progress. 01.22.08 Process monitor, Completed and Working.. */ #include #include #include #include int print_current_time(); int main(int argc, char * argv[]) { /*Indicates whether this program will print all processes, or just those belonging to the current user.*/ int all_process_mode = 0; /*First, we determine what process we should report by looking at the arguments If there is more than one argument (the first argument is always the program name)*/ if (argc > 1) { /*If there are > 3 arguments, then return with an error, since we only handle 2.*/ if (argc > 3 ) { printf("usage: %s [-A]", argv[0]); return 0; } else { /*If the argument is -A, then set the program to return all processes*/ if (strcmp(argv[1], "-A") == 0 || strcmp(argv[1], "-a")) { all_process_mode = 1; } /*otherwise, return with an error.*/ else { printf("usage: %s [-A]", argv[0]); return 0; } } } print_current_time(); /*implement all your stuff here.*/ return 0; } /*Prints out the current system time*/ int print_current_time() { struct timeval now; /*Get the current time*/ gettimeofday(&now, NULL); /*ctime takes in the current time in unix seconds and returns the time in "dow mon dd hh:mm:ss yyyy" format.*/ printf("Process Monitor report at %s\n", ctime(&(now.tv_sec))); return 0; }