Hey guys, I'm new to UNIX, trying to teach myself and came across this practice question in the book im using. My guess is that the program terminating simply calls the exit function if an invalid input is passed to it. Please let me know if I'm on the correct path! Thanks guys!
views:
34answers:
1That's one way for a program to terminate. If you call exit
with a non-zero number, the program will have "exited normally with error status". There are other ways. If someone kill
s the process, it will die abnormally. If the program segfaults (accesses an address that isn't mapped to it), it'll be killed with SIGSEGV.
That answers the question of "what causes a program to terminate". That doesn't quite answer "what process is undertaken", which probably means "what does the kernel do when a program crashes?" I don't know all the gory details, but I know that when a program does something illegal, it doesn't (unless there's a bug in the kernel or something) corrupt memory of any other part of the system, it just stops the program from running and returns the resources it was using to the system.