Question: Function bool app_initialize in argn, char *argull) shall initialize the server by executing the following tasks: 1. Check the number of command-line parameters. If there




Function bool app_initialize in argn, char *argull) shall initialize the server by executing the following tasks: 1. Check the number of command-line parameters. If there are more than two parameters, report an error to stderr and return false. If there are two parameters, check if the second parameter is a positive integer number with atoi(). If not, report a usage message to stderr with fprintf() and return false. If it is, assign it to the global variable PORT (provided; the default value is 8000). 1 2. Change the server's working directory to APP_WD (defined in ybruf.h) with chdir(). If the function fails, report the error with perror() and return false. 3. Create a new file called ybruf.pid, and write the server's process ID into that file as a decimal number. If the file exists, overwrite it. If the file cannot be created or in the case of a write error, report the error with perror() and return false. 4. On success, return true. Function void app_terminate(int signo) is a signal handler. It shall be invoked when the server receives the signals USR1 or USR2. If the signal is USR1 ("soft" termination), the server shall wait for the subsequent request and stop without accepting it (change the variable done). If the signal is USR2 ("hard" termination), the server shall exit at once with EXIT_SUCCESS. Additional action will be added to this scenario later. 1 #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
