awarbler / yashd_project

0 stars 0 forks source link

Modify serveClient to Handle Control Signals #23

Closed awarbler closed 1 month ago

awarbler commented 1 month ago

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"); } } }

awarbler commented 1 month ago

https://github.com/awarbler/yashd_project/commit/4a4a9bef18b30d9406021cb4486120f8d0a678e7