[ee122] How should the program behave when user inputs Ctrl_D?

Richard Schmidt 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!
> Linda
> _______________________________________________
> ee122 mailing list
> ee122 at mailman.ICSI.Berkeley.EDU
> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/ee122<http://mailman.icsi.berkeley.edu/mailman/listinfo/ee122>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ICSI.Berkeley.EDU/pipermail/ee122/attachments/20070922/0a1914ac/attachment.html 

More information about the ee122 mailing list