[ee122] How should the program behave when user inputs Ctrl_D?
huntingtonsurfca at gmail.com
Sat Sep 22 18:55:33 PDT 2007
Ctrl-C (An interrupt) will kill the process currently running. So there's no
way for you to say, "If user kills my program, do this."
Ctrl-D (EOF) However is a user-inputted key, and can be interpereted as the
macro <EOF>. Thus, if encountered your program will still be running after
it sees it, so it would be logical to close sockets and free up all your
malloc'd space before closing the process.
Then give a return value to your main function (mine is of type int so I
return 0 for success).
On 9/22/07, Linda Sha <lindablus at berkeley.edu> wrote:
> I have trouble using cin to capture the "EOT"/Ctrl_D character. My program
> client program stopped running after I input Ctl-D + ENTER, but it won't get
> back to the command line either (unless I press ctrl_c). How should we deal
> with this character?
> For Ctrl_C, is it ok to let the program terminate without closing the
> socket etc?
> Thanks a lot!
> ee122 mailing list
> ee122 at mailman.ICSI.Berkeley.EDU
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ee122