Shared Memory & Detach

7 views
Skip to first unread message

Keith Sammut

unread,
Mar 22, 2012, 5:41:11 AM3/22/12
to SystemsProgramming2011_12
Hi Sir,

We are using shared memory on the server side and obviously we need to
detach the segment once the server quits.....correct?

In order to quit the server we need to perform a blocking getchar()
call so we can quit the server using a key press. However, since this
is blocking the server will not accept any client requests at this
time. Is there any way around this please?

Regards,
Keith

Joseph Cordina

unread,
Mar 24, 2012, 8:47:48 AM3/24/12
to systemsprogr...@googlegroups.com
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

Keith Sammut

unread,
Mar 29, 2012, 9:48:11 AM3/29/12
to SystemsProgramming2011_12
Thank you, this helped
Reply all
Reply to author
Forward
0 new messages