Modify serveClient to Handle Control Signals:
Inserver code,i already handled receiving control signals like CTL c and CTL z.
focus on ensuring they work as expected.
Inside the serveClient function, I should have the following logic to send the appropriate signal (SIGINT or SIGTSTP) to the process (pid) that's running the current job:
else if (strncmp(buffer, "CTL ", 4) == 0) {
char controlChar = buffer[4];
if (controlChar == 'c') {
if (pid > 0) {
kill(pid, SIGINT); // Send SIGINT to the child process
printf("Sent SIGINT to child process %d\n", pid);
} else {
printf("No process to send SIGINT\n");
}
} else if (controlChar == 'z') {
if (pid > 0) {
kill(pid, SIGTSTP); // Send SIGTSTP to the child process
printf("Sent SIGTSTP to child process %d\n", pid);
} else {
printf("No process to send SIGTSTP\n");
}
}
}
Modify serveClient to Handle Control Signals: Inserver code,i already handled receiving control signals like CTL c and CTL z. focus on ensuring they work as expected. Inside the serveClient function, I should have the following logic to send the appropriate signal (SIGINT or SIGTSTP) to the process (pid) that's running the current job: else if (strncmp(buffer, "CTL ", 4) == 0) { char controlChar = buffer[4]; if (controlChar == 'c') { if (pid > 0) { kill(pid, SIGINT); // Send SIGINT to the child process printf("Sent SIGINT to child process %d\n", pid); } else { printf("No process to send SIGINT\n"); } } else if (controlChar == 'z') { if (pid > 0) { kill(pid, SIGTSTP); // Send SIGTSTP to the child process printf("Sent SIGTSTP to child process %d\n", pid); } else { printf("No process to send SIGTSTP\n"); } } }