Project 2 - Deadline: 12 Noon Oct 28 - Issue: Input can come from one of two sources * User - Ordinary read * Message queue - Read in signal handler - Commands can update your data file. Keep a pristine backup handy! - Packets should be predictable in size * Can the server know how many bytes to pull off the message queue? > Consider: Can any process have pid < 10? This would allow encoding commands in msgtyp. + A union might be useful for the varying packets * Note: Be sure to use a cast for the msgp, as it is a void pointer - Script commands should be of form p2cli < * Script file should contain all keystrokes to run completely. Log file: - May be binary, but you must include a way to display it in plain text. - Does the log file persist? In final version, no. You may want it to persist for testing the log file command. IMPORTANT: Q)uit command should use Q. Key client-server rule: Do as much error checking as possible in the client. Signals - Signals are generated in the kernel and sent to a process: * All signals have a default action. Most can be set to a different action > Actions: Block, Catch, Ignore, Default + A blocked signal will eventually be unblocked and at that time can be caught, ignored, or allowed to act by default > Signals are handled by default in the following manners: Terminate, ignore List: https://dsa.cs.tsinghua.edu.cn/oj/static/unix_signal.html - signal() sets up a signal handler for a particular signal * Example signal(SIGINT, removeQ) sets up the program to catch the signal and call removeQ, which is a handler. > A signal handler can have only one parameter, and that can only be an int for the signal #. - A signal mask is a bit string with each element representing one signal. * sigprocmask is used to set selected signals to block or unblock the signals whose corresponding bits are set in the sigmask, which is of type sigset_t. sigemptyset(&sigset); // Clear the sigset_t ; all signals unset sigfillset(&sigmask); // Set all bits in the sigset_t sigaddset(&sigset,signalNum); // Set the bit for signalNum sigdelset(&sigset,signalNum); // Unset the bit for signalNum sigprocmask(SIG_BLOCK,&sigset,&oldset);// For all signals with bit set, the action on that signal will be to block it. sigprocmask(SIG_UNBLOCK,&sigset,&oldset);// For all signals with bit set, the action on that signal will be to unblock it. sigpending(&pendingset); // Get all signals that are currently blocked and waiting to be active pending set is an export parameter - has sigset_t when it returns sigismember(&pendingset,i) // Returns 0 or 1 depending on whether signal i is in pendingset Notes: - 19 is SIGSTOP - 18 is SIGCONT - In sigprocmask(SIG_BLOCK,&sigset,&oldset), sigset is the new_mask, and oldset is old_mask (relative to sigprocmask specs).