Hi,
first you should not use a blocking getchar(), you really should trap termination signals since the common way of shutting down a server is to send it a SIGINT signal (or CRTL^C). Additionally even if you were blocking on a getchar(), you can always span off a different process to handle the connections.
Also you do not necessarily need to detach the memory since that is automatic on destruction of the process memory space, but you really need to IPCRM the shared memory on exiting.
Regards
Joseph Cordina