mikeizbicki / ucr-cs100

open source software construction course
Other
485 stars 407 forks source link

signal handling #96

Closed kryne001 closed 10 years ago

kryne001 commented 10 years ago

I don't get how the signal handling is supposed to work. I have a function to catch the ^C signal but it just kills the program.

bmars003 commented 10 years ago

Try taking another look at Lab 6: Signal Handling.

kryne001 commented 10 years ago

that's exactly what I did but idk I don't really see how it's not working. I thought if I catch the signal, I go into a function that kills the process but I doubt that's what should be happening.

bmars003 commented 10 years ago

You seem to be on the right track. It then comes down to what does the function that gets called doing by catching the interrupt doing.

kryne001 commented 10 years ago

I just don't get how I'm supposed to restart rshell, seeing how my rshell runs in an infinite loop. I tried putting continue in my function, but obviously that won't work because continue is in a function separate of the loop

bmars003 commented 10 years ago

huh? Why would you need to restart rshell?

kryne001 commented 10 years ago

isn't cntl+c supposed to reset the command line in rshell? instead of stopping the program altogether?

bmars003 commented 10 years ago

No, per the specs. The shell should not exit when the user types ^C. Instead, the current foreground job should interrupt.

What this means is when ^C is pressed you need to have your rshell send the appropriate signal to the current foreground process.

kryne001 commented 10 years ago

How would I interrupt the current foreground project? I'm trying to google a way to do it, can't find anything so far.

mikeizbicki commented 10 years ago

One easy way to do it is run kill on the child process.